I run this code and core dumped...
#include <string.h>
#include <stdio.h>
int main()
{
char *a= "ls";
char *b= "ls -l";
char *t = strtok(b," \t");
if (!strcmp(a,t))
printf("EQU\n");
else
printf("NOT EQU\n");
}
But after I change char *b="ls -l";
to char b[]="ls -l"
, it works.
Why?
I know that One is an array, and the other is a pointer. But are they different for strtok? And the manual page for strtok says that the first argument should be a char*.