Help me please I can not find the error. Thanks for comments

#include <iostream>
#include <string>
#include <fstream>
using namespace std;

int main()
{
string aj;
string b;
while (getline(cin,b))
{
aj += b + 'n';
}
cout<<aj;
ofstream file ("D:\file.txt");
if (file.is_open())
{
File aj;
File.close ();
cout<<"Save";
}
else {
cout<<"Error";
}
return 0;
}
First, using code tags and proper indentation makes a code much more readable.
See http://www.cplusplus.com/articles/jEywvCM9/

Second, you say "the error", but don't describe us what that error is.


Line 18?
1
2
3
4
5
6
7
ofstream file ("D:\file.txt"); <-- Not gonna use that?
if (file.is_open())
{
    File aj;  <-- ?
    File.close ();
    cout<<"Save";
}
Last edited on
Topic archived. No new replies allowed.