Notepad program

I am having issues with a very simple notepad program I am building. The bolded line has this issue:
error: no match for 'operator>>' in 'a_file >> file'





#include <iostream>
#include <fstream>
#include <cstring>

using namespace std;

int main()
{
string filename;
string file;
string userinput;
string a = a;
string b = b;

cout<<"Would you like to:\n a) Create a new text document or\n b) Open a previous document?\n";
cin>>userinput;
if (userinput==a)
{
cout<<"File name: \n";
cin>>filename;
ofstream a_file (filename.c_str());
cout<<filename<<"is ready for use.\n";
while(getline(cin, file) && file != "quit")
{
a_file<<file<<endl;
}
}
else if (userinput==b);
{
cout<<"File you want to open: \n";
cin>>filename;
ofstream a_file (file.c_str());
a_file>>file;
cout<<file<<endl;
}
cin.get();
}
The o in ofstream means output and what you are trying to do here with >> is input.
Last edited on
Thanks that solved it. I don't know how I overlooked that.
Topic archived. No new replies allowed.