W
william
I received a segfault error in a very short program for test purpose.
I found no luck even if I read some tricks about tracking down the
segfault. Can any one give me a hint which line of the following code
caused the problem?
******************************************
1 #include <stdio.h>
2 #include <string.h>
3
4 int main (int argc, char** argv)
5 {
6 char** tokens;
7 char * pch;
8 int i=0;
9 pch = strtok (argv[1],"/");
10 while (pch != NULL)
11 {
12 if(pch!=NULL)
13 tokens=pch;
14 i++;
15 printf ("%s\n",pch);
16 pch = strtok (NULL, "/");
17 }
18 printf("i=%d\n",i);
19 return 0;
20 }
****************************************
I found no luck even if I read some tricks about tracking down the
segfault. Can any one give me a hint which line of the following code
caused the problem?
******************************************
1 #include <stdio.h>
2 #include <string.h>
3
4 int main (int argc, char** argv)
5 {
6 char** tokens;
7 char * pch;
8 int i=0;
9 pch = strtok (argv[1],"/");
10 while (pch != NULL)
11 {
12 if(pch!=NULL)
13 tokens=pch;
14 i++;
15 printf ("%s\n",pch);
16 pch = strtok (NULL, "/");
17 }
18 printf("i=%d\n",i);
19 return 0;
20 }
****************************************