Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdlib.h>
- #include <fstream>
- #include <string>
- using namespace std;
- void createfile();
- void rfile();
- void wfile();
- void tfile();
- int main ()
- {
- int op;
- do
- {
- system("cls");
- cout<<"1.c file"<<endl;
- cout<<"2.r file"<<endl;
- cout<<"3.w file"<<endl;
- cout<<"4.t file"<<endl;
- cout<<"5. exit"<<endl;
- cout<<"select 1/2/3/4/5"<<endl;
- cin>>op;
- switch(op)
- {
- case 1: createfile();system("pause");break;
- case 2:wfile();system("pause");break;
- case 3:rfile();system("pause");break;
- case 4:cout<<"4";system("pause");break;
- case 5:
- {
- char ch;
- cout<<"exit with <y>";
- cin>>ch;
- if (ch=='y')
- op=0;
- }
- default:
- cout<<"invalid operation"<<endl;
- break;
- }
- }
- while(op!=0);
- return 0;
- }
- void createfile()
- {
- fstream file("testfile.txt", ios::in|ios::out);
- file.close();
- }
- void wfile(){
- ofstream file;
- file.open("testfile.text");
- file<<"text";
- file.close();
- }
- void rfile()
- {
- ifstream file;
- file.open("testfile.text");
- string data;
- getline(file,data);
- cout<<data<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement