Experiment No-11
Experiment No-11
#include<iostream>
#include<fstream>
int main()
ofstream onfile;
onfile.open("D:\\file.txt");
onfile.close();
return 0;
}
// Write File
#include<iostream>
#include<fstream>
int main()
ofstream onfile;
onfile.open("D:\\file.txt");
onfile.close();
return 0;
}
// Read File
#include<iostream>
#include<fstream>
int main()
ifstream infile;
string str;
infile.open("D:\\file.txt");
while(getline(infile,str))
cout<<str;
infile.close();
return 0;
}
// Copy File
#include<iostream>
#include<fstream>
int main()
ifstream infile;
ofstream onfile;
char str;
infile.open("D:\\file.txt");
onfile.open("D:\\file_New.txt");
while(infile.get(str))
onfile.put(str);
cout<<"Copied";
infile.close();
onfile.close();
return 0;
}
// Delete File
#include<iostream>
#include<fstream>
int main()
int value=remove("D:\\file_New.txt");
if (value==0)
cout<<"file Deleted";
else
return 0;