Вы находитесь на странице: 1из 9

#include<iostream.

h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
#include<fstream.h>
#include<stdio.h>
#include<pocess.h>
class editor
{
public:
char input[100];
void firstpage();
void secondpage();
void newfile();
void openfile();
void copyfile();
void saveasfile();
void editfile();
void removefile();
void exiteditor();
}s;
void editor::firstpage()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc\\bgi");
setcolor(7);
setbkcolor(13);
setcolor(4);
setfillstyle(4,7);
floodfill(0,0,1);
rectangle(8,20,628,460);
rectangle(1,13,635,467);
settextstyle(7,0,6);
outtextxy(160,20,"WELCOME");
delay(200);

outtextxy(260,70,"TO");
delay(200);
outtextxy(160,20,"EDITOR");
delay(200);
settextstyle(7,0,3);
delay(200);
outtextxy(160,20,"Developed By:");
delay(200);
settextstyle(7,0,2);
outtextxy(350,430,"press any key to continue..................");
}
void editor::secondpage()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc\\bgi");
setcolor(7);
setbkcolor(13);
setcolor(4);
setfillstyle(4,7);
floodfill(0,0,1);
rectangle(8,20,628,460);
rectangle(1,13,635,467);
settextstyle(7,0,6);
outtextxy(160,20,"Enter your Choice");
settextstyle(7,0,6);
delay(200);
outtextxy(160,20,"1.New");
delay(200);
outtextxy(260,70,"2.Open");
delay(200);
outtextxy(160,20,"3.Edit");
delay(200);
outtextxy(160,20,"4.Save As");
delay(200);

outtextxy(160,20,"5.Copy");
delay(200);
outtextxy(160,20,"6.Remove");
delay(200);
outtextxy(160,20,"7.Exit");
delay(200);
settextstyle(7,0,3);
delay(200);
outtextxy(300,400,"press 'e' to exit");
delay(200);
outtextxy(350,430,"press any key to continue..................");
}
void editor::newfile()
{
clrscr();
char c,d,n[15];
cout<<"\n\n\n*******************New file creation
mode********************";
cout<<"\n Enter file name=";
cin>>n;
cout<<"\n Enter text to file=";
ofstream open(n,ios::out);
gets(s.input);
open.write((char*)&s,sizeof(s));
open.close();
delay(300);
cout<<"\n file has been successful created";
}
void editor::openfile()
{
clrscr();
char c,n[20];
cout<<"*******************open file
mode*********************";

cout<<"\n enter file name=";


cin>>n;
delay(300);
cout<<"\n file content is=";
ifstream read(n);
while(read)
{
read.get(c);
cout<<c;
}
read.close();
}
void editor::copyfile()
{
clrscr();
char c,n[20],m[20];
cout<<"***********************copy file
mode******************";
cout<<"\n enter file name=";
cin>>n;
cout<<"\n enter new file name=";
cin>>m;
ifstream read(n);
ofstream open(m);
while(read)
{
read.get(c);
open.put(c);
}
read.close();
open.close();
delay(500);
cout<<"\n\n file copied";
}

void editor::editfile()
{
clrscr();
char c,n[20],m[20];
cout<<"***********************edit file
mode******************";
cout<<"\n enter file name=";
cin>>n;
delay(300);
cout<<"\n file content are--";
cin>>m;
ifstream read(n);
while(read)
{read.get(c);
cout<<c;
}
read.close();
delay(300);
cout<<"do you want to append text to file(y/n)";
char y;
cin>>y;
if(y=='y')
{
delay(300);
cout<<"enter text here";
ofstream open(n,ios::app);
gets(s.input);
open.write((char*)&s,sizeof(s));
open.close();
}
delay(200);
cout<<"file has been successfully appended";
}
void editor::saveasfile()

{
clrscr();
char c,n[20],m[20];
cout<<"*****************save file mode****************";
cout<<"\n enter file name=";
cin>>n;
cout<<"\n enter new file name=";
cin>>m;
ifstream read(n);
ofstream open(m);
while(read)
{
read.get(c);
open.put(c);
}
read.close();
open.close();
delay(500);
cout<<"\n\n file saved as successfully";
}
void editor::removefile()
{
clrscr();
char c,n[20],m;
cout<<"*****************remove file
mode***************";
cin>>n;
delay(300);
cout<<"\n do you want to remove file(y/n)-";
cin>>m;
if(m=='y')
{
if(remove(n)==0)
cout<<"\n file has been successfully removed ";
else

cout<<"\n error occured";


}
}
void editor::exiteditor()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc\\bgi);
setbkcolor(14);
setfillstyle(4,10);
floodfill(0,0,1);
setcolor(3);
rectangle(8,20,628,460);
rectangle(1,13,635,467);
setcolor(1);
settextstyle(4,0,9);
outtextxy(40,120,"GOOD BYE");
delay(2000);
exit(0);
}
void main()
{
editor e;
e.firstpage();
char ed;
ed=getch();
delay(508);
aa:
e.secodpage();
char cha;
cha=getch();
if(cha=='e')
exit(0);
delay(1500);
clrsrc();
editor f;

char a;
cout<<"enter your choice==";
cin>>a;
switch(a)
{
case'1':
{
f.newfile();
break;
}
case'2':
{
f.openfile();
break;
}
case'3':
{
f.editfile();
break;
}
case'4':
{
f.copyfile();
break;
}
case'5':
{
f.saveasfile();
break;
}
case'6':
{
f.removefile();
break;
}

case'7':
{
f.exiteditor();
break;
}
default:
{
cout<<"wrong entry";
delay(1000);
goto aa;
}
}
delay(300)
cout<<"\n\n\n do you want to continue(y/n).........";
char p;
cin>>p;
if(p=='y')
goto aa;
else
exit(0);
getch();
}

Вам также может понравиться