Question: Ex 4 . 1 0 , 1 1 : Replace C 9 9 comments The original 1 9 8 9 ANSI / 1 9 9

Ex4.10,11: Replace C99 comments
The original 1989 ANSI /1990 ISO C standard (ANSI C, C90) only permits /**/ style comments:
??** This is a comment **?
??** This is
a multiline comment */
The 1999 ISO standard (C99) provides line-oriented comments starting with a // combination:
Task
Starting with the program fortcomm.c shown in Figure 4.13 on page 58(also found in "Reading
data with loops"), write a program that replaces each c99-style comment in the input text by an
equivalent ANSI C comment.
That is, each // pair that commences a comment should be replaced by ??***, and then a */
combination should be inserted immedlately prior to the next newline character.
Sample output
The program should not prompt for input. Any input given to it should be outputted with C99-style
comments being replaced with ANSI C comments.
// My useful program
#include stdio.h>
int main() Our main function */
printf("Hello world! {:?
?n);????? print hello
// done, phew!
return
}
bash$ ./program input.c
??** My useful program */
#include {:?
?n);**a**???????******************************???{:?
?n);**?????????***??*********************************???**:?*
?n*;???
 Ex4.10,11: Replace C99 comments The original 1989 ANSI /1990 ISO C

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!