read a file in c line by line

What if you drop the pointers ..

char ch;
char word[45];    
for (int i = 0; ;i++)
{
    ch = fgetc(ptr);
    word[i] = ch;
    if (ch == 10)
    {
        break;
    }
}
printf("%s\n", word);

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top