Answer the question
In order to leave comments, you need to log in
C - How to output lines of a certain length (> 60 characters) from a file?
Greetings. The following C (not C++) program simply prints all lines to the screen.
#include <stdio.h>
void main()
{
FILE * fil;
int temp;
char mem;
fil = fopen("D:\\FilesProjects\\1file.txt", "rt");
while (!feof(fil))
{
int res;
res = fscanf(fil, "%c", &mem);
if (res == EOF)
break;
printf("%c", mem);
}
printf("\n");
fclose(fil);
system("pause");
}
#include <stdio.h>
void main()
{
FILE * fil;
int temp;
char mem;
fil = fopen("D:\\FilesProjects\\1file.txt", "rt");
while (!feof(fil))
{
int res;
res = fscanf(fil, "%c", &mem);
if (res == EOF)
break;
if (strlen(mem) <= 60)
{
printf("%c", mem);
}
}
printf("\n");
fclose(fil);
system("pause");
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question