void GetSymbol ()
{
char *s, *tp;
char sep[2] ;
sep[0] = ' '; sep[1] = '\0';
gets(s);
tp = strtok (s,sep);
while (tp != NULL)
{
printf("%s\n",tp);
tp = strtok (NULL,sep);
}
}
int main()
{
GetSymbol();
return 0;
}
void GetSymbol ()
{
char *s, *tp;
char sep[2] ;
sep[0] = ' '; sep[1] = '\0';
gets(s);
tp = strtok (s,sep);
while (tp != NULL)
{
printf("%s\n",tp);
tp = strtok (NULL,sep);
}
}
int main()
{
GetSymbol();
return 0;
}
You didn't assign any memory to *s
gets() is old an bad, dont use it (use fgets() )
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
>char *s, *tp;
s is just a pointer. Allocate some space for it with malloc() or do this instead:
char s[100], *tp;