diff --git a/ReadWrite.cpp b/ReadWrite.cpp new file mode 100644 index 0000000..6f2d44f --- /dev/null +++ b/ReadWrite.cpp @@ -0,0 +1,49 @@ +#include + +#include + +using namespace std; + +int main() { + + ofstream MyFile("sample.txt"); + + cout<<"Writing into a file\n"; + + string data; + + cout<<"Enter your name : \n"; + + cin>>data; + + + + MyFile << data << endl; + + cout<<"Enter your age : "; + + cin>>data; + + MyFile << data << endl; + + + + MyFile.close(); + + string myText; + +ifstream MyReadFile("sample.txt"); + +cout<<"Reading from a file\n"; + +while (getline (MyReadFile, myText)) { + + cout << myText<