-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtext_editor.cpp
72 lines (62 loc) · 1.33 KB
/
text_editor.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
void write_file(char *str){
ofstream out;
char data[100];
out.open(str, ios::out | ios::app);
cout<<"File created"<<endl;
cout<<"Enter the data to be entered in file"<<endl;
cin.ignore();
cin.getline(data, 100);
out<<data<<endl;
}
void seperate_file(char *str) {
int i=-1;
ifstream in;
ofstream outV, outC;
char data, a[100];
in.open(str, ios::in);
outV.open("vowels.txt", ios::out);
outC.open("consonants.txt", ios::out);
while(!in.eof()){
in.get(data);
if(data == 'a' || data == 'e' || data == 'i' || data == 'o' || data == 'u' || data == 'A' || data == 'E' || data == 'I' || data == 'O' || data == 'U'){
outV<<data<<" ";
} else {
outC<<data<<" ";
}
}
}
void delete_file(char *str) {
if(remove(str)!=0)
cout<<"Error deleteing file!";
else
cout<<"file successfully deleted!";
}
int main() {
char file[100];
int choice;
cout<<"Enter the file name : ";
gets(file);
cout<<endl<<"1. Write"<<endl<<"2. Read"<<endl<<"3. Delete"<<endl;
cin>>choice;
switch(choice) {
case 1: {
write_file(file);
break;
}
case 2: {
seperate_file(file);
break;
}
case 3: {
remove(file);
break;
}
default : {
cout<<"wrong input";break;
}
}
}