A simple code to open a file and write something and read from a file...(C++)
But something is wrong here..
Let me know...what it is!!!
Comment below..!!!!
#include<iostream>
#include<sstream>
#include<fstream>
using namespace std;
int main()
{
fstream fobj;
string filename = "/home/ferdose/Desktop/file.txt";
string str;
fobj.open("filename",ios::in|ios::out);
if(!fobj) cerr<<"Can't open"<<endl;
fobj>>str;
fobj<<"hey"<<endl<<"hello";
cout<<str;
}
But something is wrong here..
Let me know...what it is!!!
Comment below..!!!!
#include<iostream>
#include<sstream>
#include<fstream>
using namespace std;
int main()
{
fstream fobj;
string filename = "/home/ferdose/Desktop/file.txt";
string str;
fobj.open("filename",ios::in|ios::out);
if(!fobj) cerr<<"Can't open"<<endl;
fobj>>str;
fobj<<"hey"<<endl<<"hello";
cout<<str;
}


