#include <stdio.h>
#include <string.h>
int main()
{
/*
char str[16] = "host:12306";
char *p;
p = strtok(str,":");
if(p)
printf("%s\n", p);
p = strtok(NULL, ",");
if (p) printf("%s\n", p);
*/
char str[] = "a,b,c,d e f g";
char *p;
p=strtok(str, ",");
while(p)
{
printf("%s\n",p);
p=strtok(NULL, ",");
}
return 0;
}
#include <iostream>
using namespace std;
int main()
{
char ip_host[] = "localhost:3306";
char *toKenPtr =strtok(ip_host, ":");
while(toKenPtr!=NULL)
{
cout << toKenPtr << endl;
toKenPtr = strtok(NULL, ",");
}
return 0;
}
#include <stdio.h>
#include <string.h>