Write a C program that displays contents of given line page by page. Given number of lines to show as ‘n’ at a time and a file name, the program should first show n lines, then wait for user to hit a key before showing next n lines and so on.
We strongly recommend to minimize the browser and try this yourself first.
We can open the given file and print contents of files. While printing, we can keep track of number of newline characters. If the number of newline characters become n, we wait for the user to press a key before showing next n lines.
Following is the requires C program.
This article is contributed by Ajay Jain. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- C program to copy contents of one file to another file
- C Program to print contents of file
- C Program to merge contents of two files into a third file
- C program to print odd line contents of a File followed by even line content
- Program to copy the contents of one array into another in the reverse order
- How to write your own header file in C?
- Read/Write structure to a file in C
- fopen() for an existing file in write mode
- lseek() in C/C++ to read the alternate nth byte and write it in another file
- C program to check whether the file is JPEG file or not
- How to use make utility to build C projects?`
- Write a C program that won't compile in C++
- C program to write an image in PGM format
- Write a program that produces different results in C and C++
- Write a C program that does not terminate when Ctrl+C is pressed
- Write a C program to print "GfG" repeatedly without using loop, recursion and any control structure?
- C program to delete a file
- C++ program to create a file
- C Program to find size of a File
- LEX program to add line numbers to a given file