Answered step by step
Verified Expert Solution
Question
1 Approved Answer
NEED IT ASAP PLEASE!!!!!! 2.3 The summary program problemlines.c The line length check program described above can give a user full information about which of
NEED IT ASAP PLEASE!!!!!!
2.3 The summary program problemlines.c The line length check program described above can give a user full information about which of their program lines are too long, and by how much. Sometimes though a user might just want to see a summary view of only the numbers of the lines that are too long, without the other information produced by the first program. You will also write a second program that reads the output of your first program and does this. This program should read the output produced by your lengthwarning. c program and print only the numbers of the lines in the input of lengthwarning. c that lengthwarning. c identified as longer than 80 characters, in increasing line number order obviously. If one or more lines in the input of lengthwarning . c had length more than 80 this program should print all their numbers, on a single output line, ending in a newline. If more than one line number is printed they should be separated by a single blank space, but there should not be any space at the beginning of the line before the first line number or any space after the last line number printed. If there were no lines with length more than 80 this program will only print a newline (it always prints at least a newline). The way this program tells if lengthwarning.c saw an input line whose length was longer than 80 is to look for an asterisk as the first character printed. Note that this program will print the numbers of the lines in the input of lengthwarning. c that were longer than 80 characters. lengthwarning . c can print more lines of output than the number of lines in its input because it prints a pair of lines for every input line that is longer than 80 characters, with the second one having spaces and caret characters; these caret lines will be ignored by problemlines. c. Here is an outline of what problemlines.c should do: - It must read a single character, which will be the first character on a line. Since it is reading output produced by lengthwarning. c it should expect that this character will either be an asterisk or a space. - If the character read was a space then this is a line read by lengthwarning.c whose length was not more than 80 , so in this case problemlines. .c must just skip the entire rest of the line whose first character was just read. To do this it should read characters (one at a time) until it sees a newline, then read the first character on the next line (if there is a next line), which will again be an asterisk or a space, and begin the process again. - If on the other hand the first character that problemlines.c read on a line was an asterisk, this means that the rest of the line read by lengthwarning . c was did have length longer than 80 . In this case problemlines. c must read a number after the character- which will be the number of the line in the input of lengthwarning. c that was too long- and print the number. Then it must skip the rest of the line, including its newline, just as in the case above, and also skip the entire next line (and its newline), which will be one containing 80 spaces followed by one or more carets. Then it will read the first character on the next line (if there is a next line) and begin the process again. This explanation omits details such as properly handling spaces between numbers printed by problemlines.c, which are up to you to figure out. The last public test illustrates the results produced by problemlines.c when there was a line in the input of lengthwarning. c that had length more than 80. problemlines.c is designed to read the output of your lengthwarning. c program. problemlines.c can be run on any other text file, as long as the file's contents follow the output format produced by lengthwarning.c. If problemlines. c is run on input that does not follow the output format of lengthwarning.c then it can produce incorrect results, or crash, or have an infinite loop. (In other words, problemlines. c is only expected to work right on input of the proper format, and there is no required behavior if its input does not follow that format.) Don't forget you can only use certain C language features in this program, as well as lengthwarning.c. 2.4 Assumptions and guarantees about the input not produce any output at all, but problemlines.c should print a single newline if its input is empty. - You are guaranteed, for both programs, that if their input is nonempty then each input line- even the last linewill always end with a newline character. When you create (nonempty) input data files of your own with Emacs for use in testing your program, be sure to press return at the end of the last line you type, so it will also end in a newline. Our input data may contain any printable characters appearing on a standard US keyboard, but for simplicity we will avoid nonprintable characters or whitespace characters other than spaces, tabs, and newlines. ( 2023 L. Herman; all rights reserved 3 - Any line in the input may have more than than 80 characters, but you may assume there will be no more than 1000 characters (any of which may be tabs) prior to the terminating newline character of any line, and that there will be no more than 99999 lines in either program's input. Since there can be up to 99999 lines in the input, all of which can be 1000 characters, it would use a lot of memory to try to read all lines of the input at once and store them all before printing anything. (In fact, your programs may use too much memory and crash if you do that.) Both programs should just read one line at a time and process it immediately, as described above, then read the next line and process it, etcStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started