strtok program crashing.
Posted
by baskin
on Stack Overflow
See other posts from Stack Overflow
or by baskin
Published on 2010-05-16T09:48:45Z
Indexed on
2010/05/16
9:50 UTC
Read the original article
Hit count: 187
c++
Hi,
the program for strtok given on http://www.opengroup.org/onlinepubs/000095399/functions/strtok.html
crashes everytime..
#include <string.h>
...
char *token;
char *line = "LINE TO BE SEPARATED";
char *search = " ";
/* Token will point to "LINE". */
token = strtok(line, search);
/* Token will point to "TO". */
token = strtok(NULL, search);
If I use a char array for variable 'line', it works. i.e. char line[] = "LINE TO BE SEPARATED" works.
Kindly explain.
© Stack Overflow or respective owner