c++ A program that delete comments from fstream file

write a program that:

a)if we encounter '//' we will ignore it and also ignore '\0'(end of the line)

b)if we encounter /* we ignore all the chars untill we encounter * / we have to check for nested comment: if other comment is opened, then we need to ignore all the chars untill both comments are closed.

if we encounter '//' inside '/*' we will do as following as section a.

input:

abc/* XYZ */
abc
/*XYZ // YYY
ZZZ /* XYZ // YYY */
ZZZ
*/
ZZZ
*/
abc

output:

abc
abc


abc
Topic archived. No new replies allowed.