Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   removing comments of type // and /* (http://www.go4expert.com/forums/removing-comments-type-t6929/)

rohit83.ken 19Oct2007 22:22

removing comments of type // and /*
 
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

DaWei 19Oct2007 23:41

Re: removing comments of type // and /*
 
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.

shabbir 20Oct2007 09:56

Re: removing comments of type // and /*
 
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.


All times are GMT +5.5. The time now is 09:14.