How can I make a C program that reads line by line from a file?
I want to pass each line into a string.

Here's my code so far:

---------------------------
#include <stdio.h>

int main()
{
    FILE *fil;
    char line[50];
    int c;

    if((fil=fopen("file.1","r")) == NULL)
    {
       printf("Couldn't open \"file.1\".\n");
       exit(1);
    }

    fgets(line, sizeof(line), fil);
    printf("%s",line);
}
---------------------------


Thanks,
Torbjørn Kristoffersen <[EMAIL PROTECTED]>

Reply via email to