I have a string like:
char string = " dog beans 1234 cat rice 0123 bird peanut 7777"
I would like split that in different variables like:
char animals[1000], food[1000], numbers[1000];
What I did until now:
int i;
while (string != NULL) {
for (i = 0, i < 1000, i++) {
strcpy(animals[i], strtok(string, " ");
strcpy(food[i], strtok(string, " ");
strcpy(numbers[i], strtok(string, " ");
}
}
The first loop is working fine, but the second one throws a segmentation fault.