about strtok()# Unix - 噫吁兮,危乎高哉
b*i
1 楼
I tried some times to solve your problem. At the first time, I got segmental
fault, but at last I am lucky to find a way to parse the tokens.Below is an
example:
#include
#include
#include
void main()
{
char *str;
char *line="15:wildwood.eecs.umich.edu:018032:24.79";
char *delimiter=":";
char *tokenp;
int numtokens,i;
if ((str=calloc(strlen(line) + 1, sizeof(char))) == NULL)
exit(1);
else {
strcpy(str, line);
fault, but at last I am lucky to find a way to parse the tokens.Below is an
example:
#include
#include
#include
void main()
{
char *str;
char *line="15:wildwood.eecs.umich.edu:018032:24.79";
char *delimiter=":";
char *tokenp;
int numtokens,i;
if ((str=calloc(strlen(line) + 1, sizeof(char))) == NULL)
exit(1);
else {
strcpy(str, line);