how could I strtok at spaces while reading in data from a buffer? If my text file contained
1 23 50
45 50 30
2 15 30
and I decide to print the array with my code below, it will print line by line. How could I extend this to further divide the array into individual numbers for each index of the array? Eg.
1
23
50, etc...
I've tried playing around with strtok but I keep segfaulting and I wasn't sure where to fix it.
FILE * fp;
char buffer[5000];
int size = 0;
char **entireFile = NULL;
fp = fopen("file.txt","r");
entireFile = malloc(sizeof(buffer) * sizeof(char*));
while (fgets(buffer,5000,fp)!= NULL)
{
entireFile[size] = malloc(strlen(buffer)+1);
strcpy(entireFile[size],buffer);
size++;
}