Hi friends,
I 'm trying to extract values from a lines which are delimited by a
space
eg.
content of string is: "Hello World"
I use strtok to extract "Hello" and "World"
the code I use is
foo=atoi(strtok (data," "));
bar=atoi(strtok (NULL," "));
BUT If in case there's only one word, it gives me Segmentation Fault.
How can I handle this?
I tried try-catch but didnt work.
Can anyone please help me with this issue?
Thanks in advance
I 'm trying to extract values from a lines which are delimited by a
space
eg.
content of string is: "Hello World"
I use strtok to extract "Hello" and "World"
the code I use is
foo=atoi(strtok (data," "));
bar=atoi(strtok (NULL," "));
BUT If in case there's only one word, it gives me Segmentation Fault.
How can I handle this?
I tried try-catch but didnt work.
Can anyone please help me with this issue?
Thanks in advance
Comment