Question: Write a program in C... Your programs should only use system calls for obtaining input and generating output. For example, use read() and write() system
Write a program in C...
Your programs should only use system calls for obtaining input and generating output. For example, use read() and write() system calls instead of C library functions (e.g. scanf or printf) to fetch input and display output.
Write a program that accepts the name of a file and enables the user to view different lines of text by interactively inputting line numbers (sequence of numbers followed by the enter key). After reading the file into a buffer, the program should repeatedly prompt the user for a line number and then display the appropriate line of text. This would continue until the read call indicates theres no more user data (interactively, youd press control-D).
You can assume that the file has less than 100 lines and that the total number of characters in the file is less than 8192 (create a static 8k buffer rather than dynamically allocating space).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
