程序代写代做代考 Homework 6 Time it took Matthew to Complete: 20 mins

Homework 6 Time it took Matthew to Complete: 20 mins
• All programs must compile without warnings when using the -Wall and -Werror options
• Submit only the files requested
◦ Do NOT submit folders or compressed files such as .zip, .rar, .tar, .targz, etc
• Your program must match the output exactly to receive credit.
◦ Make sure that all prompts and output match mine exactly.
◦ Easiest way to do this is to copy and paste them
• All input will be valid unless stated otherwise
• Print all real numbers to two decimal places unless otherwise stated
• The examples provided in the prompts do not represent all possible input you can receive.
• All inputs in the examples in the prompt are underlined
◦ You don’t have to make anything underlined it is just there to help you differentiate between what you are supposed to print and what is being given to your program
• If you have questions please post them on Piazza
Restrictions
• No global variables are allowed
• Your main function may only declare variables, call other functions, and assign
variables values.
Files to submit: tail.c

Write a program called tail.c that prints out the last N lines of a given file
1. Arguments to your program will be passed on the command line in the
following order
1. Name of the file 2. N
2. N will always be at least 1
3. If N is greater than the number of lines in the file, all of the lines in the file
should be displayed
4. You may assume that no line is longer than 100 characters
1. For an additional challenge try to solve the problem where there is no limit on the length of a line
1. My solution to dealing with any length lines involved using the
functions ftell and fseek.
5. There is no limit to the number of lines in a file
6. Some lines may only contain the newline character, these still count as a line
7. My editor automatically added 1 newline character to the end of most of the
test files but does not display them. Your editor may or may not display them but do be aware that they are there.
Example. Assume the file meme.txt contains the following
It
is
over 9000!!!
1../tail.out meme.txt 1 over 9000!!!
2../tail.out meme.txt 2 is
over 9000!!! 3../tail.out meme.txt 10
It
is
over 9000!!!