Here is a comment stripper program from which takes input from Cin and removes the comments.
#include <iostream>
#include <fstream>
char Getchar();
char var;
int main()
{
char ch;
do
{
Getchar();
switch(var)
{
case '/':
switch(Getchar())
{
case '*':
Getchar();
while(true)
{
if(var=='*'&&Getchar()=='/')
{
break;
}
else
{
Getchar();
}
}
break;
case '/':
while(Getchar()!='\n');
std::cout<<'\n';
break;
default:
break;
}
break;
case '"':
do
{
std::cout<<var;
}
while (Getchar()!='"');
std::cout<<var;
break;
default:
std::cout<<var;
}
}
while(var!='x');
}
char Getchar()
{
std::cin.get(var);
return var;
}
So any improvements ?
Secondly I am looking for another way by which i can close input any suggestions on that.
I mean this program exits when "x" is inputted. Is there any other way of Exiting?