Question

My program will open a file and print the contents in the terminal. As the file is large, the terminal goes two or more page. I'll have to slide up to the first line of the file to read from the beginning. Is it possible using C program?

void hfile()
{
printf("\033[2J");
printf("\033[0;0H");
FILE *ffp;
char c;

ffp=fopen("help.txt","r");
while((c=getc(ffp))!=EOF)
    printf("%c",c);

}
Était-ce utile?

La solution

Not via stdlib. You will have to use some third-party library like ncurses.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top