I am a noob in C and studying the STRTOK function. I have found an example code where a pointer is used. but i don't know the reason why. Can anyone explain why?
int main()
{
char str[80] = "I love you";
const char s[2] = " ";
char *token;
token = strtok(str, s);
while( token != NULL )
{
printf( " %s\n", token );
token = strtok(NULL, s);
}
return(0);
}
I just read a text about this function. I found that, strtok function returns a pointer value itself. That's why we have used pointer here ( *token) I
Aucun commentaire:
Enregistrer un commentaire