I HAVE A PROGRAM THAT I CONNECTED TO NOTEPAD. IT WORKED BUT THE OUTPUT ON MY PROGRAM CAN'T DISPLAY ON NOTEPAD. NOTEPAD JUST DISPLAY QUESTION MARK '?'. HERE'S MY CODE.
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <string>
usingnamespace std;
int main(int argc, char *argv[])
{
string name;
int right =10;
cout<<" Enter your name: ";
cin>>name;
cout<<endl<<endl;
cout<<" Your name is "<<name <<" and your score is "<<right<<endl<<endl;
ofstream MyScore ("myscore.txt");
MyScore << name <<" " <<right;
MyScore.close ();
system("PAUSE");
return EXIT_SUCCESS;
}
Does it work if you use a name that consists of pure ASCII characters (like "Cassie")?
Are you sure you are looking at the correct file?
Are you sure the file is opened correctly? On Windows it can fail to open the file if some other program has opened the file already. Put something like this right after line 17 to make sure.
1 2 3 4
if (!MyScore)
{
cout << "Error! Failed to open file." << endl;
}