Hi, I need help with this, I'm reading a txt file that has this format:
10,4,12,6,18,24,7,8,15,14,25,2
So far, I read the file using fopen ().Also, I used strtok () to split the string into tokens, but i don't know how store the tokens into an array.
any ideas?
thanks
#include <stdio.h>
#include <string.h>
int main()
{
FILE * pFile;
char mystring [100];
char * datos;
pFile = fopen ("intermemory.txt" , "r");
if ( fgets (mystring , 100 , pFile) != NULL )
{
puts (mystring);
fclose (pFile);
}
//printf ("\nSplitting string \"%s\" into tokens:\n",mystring);
datos = strtok (mystring,",");
while (datos != NULL)
{
printf ("%s\n",datos);
datos = strtok (NULL, ",");
}
return 0;
}