H
hu
hi, everybody!
I'm testing the fuction of strtok(). The environment is WinXP, VC++6.0.
Program is simple, but mistake is confusing. First, the below code can get
right outcome:"ello world, hello dreams."
#include <stdafx.h>
#include <string.h>
#include <stdio.h>
int main()
{
char *pStr = "Hello world, hello dreams.";
char *p = pStr;
p = strtok(pStr, "H");
if (NULL==p)
printf("null__");
else
printf("%s", p);
return (0);
}
Second, Changing the sentence:
p = strtok(pStr, "H");
to
p = strtok(pStr, "Ho");
It can be compiled, but cannot run!
Third, Changing the sentence:
p = strtok(pStr, "H");
to
p = strtok(pStr, "e");
It can be compiled, but cannot run too!
Where is the wrong?
thanks!
I'm testing the fuction of strtok(). The environment is WinXP, VC++6.0.
Program is simple, but mistake is confusing. First, the below code can get
right outcome:"ello world, hello dreams."
#include <stdafx.h>
#include <string.h>
#include <stdio.h>
int main()
{
char *pStr = "Hello world, hello dreams.";
char *p = pStr;
p = strtok(pStr, "H");
if (NULL==p)
printf("null__");
else
printf("%s", p);
return (0);
}
Second, Changing the sentence:
p = strtok(pStr, "H");
to
p = strtok(pStr, "Ho");
It can be compiled, but cannot run!
Third, Changing the sentence:
p = strtok(pStr, "H");
to
p = strtok(pStr, "e");
It can be compiled, but cannot run too!
Where is the wrong?
thanks!