[go: up one dir, main page]

0% found this document useful (0 votes)
26 views4 pages

C++ Text Editor Functionality Guide

The document is a C++ program for a simple text editor that allows users to create, view, append, and delete text files. It provides a command-line interface with options for each operation and uses file handling to manage the contents. The program runs in a loop until the user chooses to exit.

Uploaded by

gokul_kris143
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views4 pages

C++ Text Editor Functionality Guide

The document is a C++ program for a simple text editor that allows users to create, view, append, and delete text files. It provides a command-line interface with options for each operation and uses file handling to manage the contents. The program runs in a loop until the user chooses to exit.

Uploaded by

gokul_kris143
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

10.

Text Editor
#include<iostream.h>
#include<conio.h>
#include<process.h>
#include<fstream.h>
#include<stdlib.h>
#include<stdio.h>

char fn[10],c;

class texteditor
{
public:
void create();
void append();
void view();
void del();
};

void main()
{
int choice;
while(1)
{
clrscr();
texteditor obj;
cout<<"\[Link]\[Link]\[Link]\[Link]\[Link]\
nENTER YOUR CHOICE:";
cin>>choice;
switch(choice)
{
case 1:
[Link]();
break;
case 2:
[Link]();
break;
case 3:
[Link]();
break;
case 4:
[Link]();
break;
case 5:
exit(0);
break;
default:
exit(0);
}
}
}

//Creation of file
void texteditor::create()
{
cout<<"\nENTER THE FILE NAME:";
cin>>fn;
ofstream fp1;
[Link](fn);
cout<<"\nENTER THE CONTENTS OF THE FILE:";
cout<<"\nSAVE AND EXIT: CTRL &S\n";
while(1)
{
c=getch();
if(c==32)
{
cout<<' ';
fp1<<c;
}
else if(c==13)
{
cout<<"\n";
fp1<<"\n";
}
else if(c==19)
{
cout<<"\nFILE SAVED AND CLOSED\n";
[Link]();
getch();
break;
}
else
{
cout<<c;
fp1<<c;
}
}
}

//Procedure for viewing the content of file


void texteditor::view()
{
char str[30];
cout<<"\nENTER THE FILE NAME:";
cin>>fn;
ifstream fp1(fn);
while(![Link]())
{
[Link](str,30);
cout<<str<<"\n";
}
[Link]();
getch();
}

//Procedure for appending data to a file


void texteditor::append()
{
cout<<"\nSAVE:CTRL &S";
cout<<"\nENTER THE FILE NAME:";
cin>>fn;
ofstream fp1(fn,ios::ate);
while(1)
{
c=getch();
if(c==13)
{
c='\n';
cout<<"\n";
fp1<<c;
}
else if(c==19)
{
break;
}
else
{
cout<<c;
fp1<<c;
}
}
[Link]();
}

//Procedure for deleting a file


void texteditor::del()
{
cout<<"\nENTER THE FILE NAME:";
cin>>fn;
remove(fn);
cout<<"\nFILE DELETED SUCCESSFULLY\n";
getch();
}

You might also like