Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please use c and Unix to finish this program, thanks! 3) (20 marks) Write a C program named a6q3.c which removes C-style comments of the

image text in transcribedimage text in transcribedimage text in transcribed

Please use c and Unix to finish this program, thanks!

3) (20 marks) Write a C program named a6q3.c which removes C-style comments of the form "/*...*/" from the input. The program must read standard input and produce standard output. Any character outside of a comment should be copied as it is. It is recommended that you use functions getchar and putchar for this copying. The comments must be skipped in copying with exception of the new-line characters. If any new-line characters are included in a comment they must be copied to the output. This is done in order to preserve line positions of the text and the total number of lines from the input to the output The program must not store text unnecessarily, meaning that it must print characters as soon as possible after reading them. Sometimes it may need to wait with a character before printing; for example, after reading a slash character it needs to wait if the next character is asterisk or not to decide whether the comment is starting or not. Remember that you need to handle only the comments of the form "/*.*/", but not line comments starting with The input may end while the program is reading a comment, in which case, you should print the following line at the end COMMENT NOT FINISHED> ending with a newline character. It is recommended that you use a finite automaton in processing, such as the following not / not S_START S SLASH S COMMENT S_ASTERISK not / and not * notand not/ You can control the state of your program using the above diagram. You still need to decide what characters to output in each state as the program reads the input

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Know how to use reservations systems to inventory demand.

Answered: 1 week ago

Question

Be familiar with the integrative servicescape model.

Answered: 1 week ago