Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

#include<stdio.

h>
#include<conio.h>
#include<iostream.h>
#include<fstream.h>
class student
{
private:
char ch,ch1;

public:
student()
{
ch1='/';
}
void copy()
{
fstream obj,obj1;
obj.open("new.cpp",ios::in);
obj1.open("copy.cpp",ios::out);
obj.get(ch);
while(!obj.eof())
{
if(ch=='"')
{
obj1.put(ch);
obj.get(ch);
while(ch!='"')
{
obj1.put(ch);
obj.get(ch);
}
}
if(ch=='/')
{
obj.get(ch);
if(ch!='/'&&ch!='*'&&ch!='\n')
{
while(1)
{
obj1.put(ch1);
break;
}

}
if(ch=='/')
{
obj.get(ch);
while(ch!='\n')
{
obj.get(ch);
}
}
else if(ch=='*')
{
while(1)
{
obj.get(ch);
if(ch=='*')
{
obj.get(ch);
if(ch=='/')
break;
else
continue;
}
}
}

else
{
obj1.put(ch);
obj.get(ch);
}
}
cout<<"copied";
obj.close();
obj1.close();
}
};
void main()
{
student object;
object.copy();
}

You might also like