Question: c programming 3. Print the first 5 lines of a file (lastname HEAD.C): Write a C program that takes a file as an argument and
3. Print the first 5 lines of a file (lastname HEAD.C): Write a C program that takes a file as an argument and prints its first 5 lines (equivalent to using head -n 5). If this program does not receive the correct number of arguments, or if it fails to open the given file, it should return errors. Hint: Write a function readLine() that reads characters until it hits a newline character - run this function in a loop to get and print 5 lines. Assume that the file has at least 5 lines. /carberryHEAD apache.txt You may add your own copyright statement to your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of your modifications, or for any such Dervative Works as a whole, provided Your use, reproduction, and distribution of the work otherwise complies with /carberryHEAD notfile Error opening file $ ./carberryHEAD Usage: /carberryHEAD File Figure 1 - Expected behavior of lastname HEAD
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
