the program for strtok given on http://www.opengroup.org/onlinepubs/000095399/functions/strtok.html crashes everytime..
#include
...
char *t
char *line
is a pointer and you are pointing it to a constant string ("LINE TO BE SEPARATED"
). This fails when strtok
attempts to modify that string. It would be better to qualify this variable as const char *line
—still wouldn't work, but might lead to a helpful warning when you try to pass it to strtok
.
Meanwhile the array char line[]
can be modified (it's not const
) and is only initialised to contain the string.