Alex.
Retired
- Joined
- Aug 24, 2005
- Messages
- 4,616
I am reading some lines from a text file, and I need to tokenize them. I used strtok() in the past successfully, but now it's causing me problems. The overall line is what I expect it to be, but each of its tokens are "0" (see code below).
The scary part is that a program that I made a while ago, that used strtok, no longer works on my GP2X (and it's the same old binary that worked a couple of days before that doesn't work now!).
CODE
#include <string.h>
...
char line[80] = "1,0,0,0,0,0,2,2,1,0";
char special[] = ",";
char* token;
int i;
for(i = 0; i < 10; i++) {
token = strtok(line, special); // token is "0" all the time!
}
I'm kind of stumped :-/
The scary part is that a program that I made a while ago, that used strtok, no longer works on my GP2X (and it's the same old binary that worked a couple of days before that doesn't work now!).
CODE
#include <string.h>
...
char line[80] = "1,0,0,0,0,0,2,2,1,0";
char special[] = ",";
char* token;
int i;
for(i = 0; i < 10; i++) {
token = strtok(line, special); // token is "0" all the time!
}
I'm kind of stumped :-/