I need help with saving inputted text to a file.
I'm making a DOS text editor (Yeah i know, dumb idea.) but I cant get the outputted file to display the whole of what the user inputted.
It can't be ultimate.h being included, because it will compile if I
remove the "string variable;" line.
Thanks in advance for any help!
Code:
#include "ultimate.h"
using namespace std;
string variable;
int main()
{
HANDLE hStdout;
hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hStdout, BACKGROUND_BLUE);
cout<<" ---[The Civic Wordedit]--- _ X"<<endl;
textcolor(LIGHTGRAY);
char variable;
cin >> variable;
ofstream fout; // this means tha fout acts for ofstream
fout.open("file.txt"); // I have no clue how to have the user pick the file name
fout << "your variable: " << variable << endl; // this couts(or fouts) wutever is in the variable calle "varibakle" into file.txt
fout.close();
system("pause");
return 0;
}
What exactly does it output?
Does it only output the first letter? that may be because variable is only a char. and why did you make it a global string? Maybe i am still too much of a n00b, but, that doesn't look right to me.