I'm having trouble writing a program that counts ten lines and displays only the characters from those lines. I want the program to read the characters one at a time from the file. I have here the code I've managed to write so far. Any help would be greatly appreciated.
Code:
#include<stdio.h>
#include<stdlib.h>
#define FNLEN 100
int main(void)
{
FILE *input;
char infilename[FNLEN];
char character;
int line_count;
printf("Enter name of text three you wish to preview: ");
scanf("%s", infilename);
input = fopen(infilename, "r");
while ((input = fopen(infilename, "r"))) == NULL)
{
printf("%s is an invalid name.\n", infilename);
printf("Please enter valid file name. ");
scanf("%s", infilename);
}
while (fscanf(input, "%c", &character) != EOF)
{
if
}
}