I have been looking for some answers about this subject but I only see stuffs like: read something with spaces and show it onto the screen.
My question is a similar one but adding a variation.
Imagine that you have in a file:
michael;man;25,34,12,34
My question is, how can you take this line and save the numbers, and only the numbers in some array?
I have been trying the typical thing of read the line and show it for doing some tests, but I can't find how to keep this part in some array:
const int NUMBEROFLINES = 4;
FILE *fp
int i;
char leer[100] = "";
fp = fopen("name.txt", "r");
if (fp == NULL)
{
perror("ERROR");
}
for (i=0;i<NUMBEROFLINES;i++)
{
fgets(read, 100, fp);
puts(read);
read[strlen(leer)] = '\0';
}
close(fp);
Aucun commentaire:
Enregistrer un commentaire