removing comments of type // and /*

Light Poster
19Oct2007,22:22   #1
rohit83.ken's Avatar
please help me in writing the code that takes a c or c++ file and deletes the comments and prints the output to other file

totally 3 files r involved
one removes the comments
other is the program having comments
other is output printed without any comments containing c or c++ code

prethanks to the helper

kindly send the source code or provide link
Team Leader
19Oct2007,23:41   #2
DaWei's Avatar
This is not a free software store. You should either

1) Attempt to write the code and ask here for help with your problems.
2) Put your request in the Job Offers forum.
Go4Expert Founder
20Oct2007,09:56   #3
shabbir's Avatar
I can share the algo with you.

Parse the characters of the file and check for // or /* but remember that they should not be under the string literal ""

Now if you find // which is not under the string literal then ignore the line
if you find /* and its not in the string literal then ignore till */
Else you write everything to the new file.

I hope it helps.