0

How to write a c program to remove all comments in a given program

31st Jan 2019, 5:59 PM
Pooja Jagadish
Pooja Jagadish - avatar
6 Réponses
+ 2
Do you want to remove all comments fron a source file in C? I so, one possible way will be to: 1. Open source file 2. Open destination file 3. Read line (if not eof) 4. Process line: a. If you find // after ; place \0 instead of the first / b. If there is /* skip the rest of the line, and set a flag to mark that you must skip following lines until you found the closing */ 5. Write "clean" line to destination file 6. Go to 3 7. Close files This is just an idea from the top of my head. Rough edges must be worked out possibly...
2nd Feb 2019, 11:24 PM
unChabon
unChabon - avatar
+ 1
This program works decently... Read one char per loop instead of one line as I suggested above. https://code.sololearn.com/cCMYe0I766ss/?ref=app
3rd Feb 2019, 4:25 PM
unChabon
unChabon - avatar
0
OK thank u diego Code
3rd Feb 2019, 2:36 AM
Pooja Jagadish
Pooja Jagadish - avatar
0
How to give a file as an input to a c program.
29th Mar 2019, 12:50 PM
Pooja Jagadish
Pooja Jagadish - avatar
0
write a c program to creat folder called my folder?
17th May 2020, 2:31 AM
Zainab abdulameer
Zainab abdulameer - avatar
0
Use system(command); command is (a string) an os command... Ej md folder
17th May 2020, 3:17 AM
unChabon
unChabon - avatar