A basic C Program to just remove all types comments from any source code file. Its written in c language and take file name as parameter when run it. Its read every character of code and remove comments to generate a clean code. This code can be compile and run using any compiler.
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
int main(int argc, char * argv[]) {
char ch, ch1;
ifstream f1;
ofstream f2;
f1.open(argv[1]);
f2.open(argv[2]);
f1.get(ch);
ch1 = ch;
do {
f1.get(ch);
if (ch1 == '/' && ch == '*') {
do {
f1.get(ch);
} while (ch != '*');
} else if (ch == '/') {
do {
f1.get(ch);
} while (ch != '\n');
f2 << '\n';
} else
f2 << ch;
} while (f1);
f1.close();
f2.close();
return 0;
}
It is a simple program to read source code file and remove all type comments and print output on command screen.

How to run:-
- First compile this program using your c/cpp compiler and create binary (.exe) file.
- Then open cmd and write your binary file name then space and now enter your source code file path.
- Now hit Enter.
Now the output will be on your screen without any comments.
You will also like full functional Linked List Program A Linked list Program in CPP with complete Functionality

Leave a Reply