I have a text file where each line is an individual record...about 242 characters long.
I made a C program that reads in the file and stores it into buffer using fgets, but it stores the whole file and not just each individual record like I need.
What I want to know is how can this be done with more than one record/line? It works flawlessly with one record but I am having trouble setting it up where it can hold the first line, execute the program, then go to the next line and so on.
Here is what I am using to grab the file. Should I be doing something with fscanf? And do I need more variables to hold each line? Thanks.
while (fgets(buffer, 500, fp) != NULL)
{
fputs(buffer, stdout);
}
Aucun commentaire:
Enregistrer un commentaire