C++ NOTEPAD ERROR

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <string>

using namespace 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;
}
Try ending the text file with a newline character.
 
MyScore << name << "      " << right << '\n';

still the same. the notepad displayed ?. Is there a problem on my code? or it just my notepad? But a few days ago it worked.
What do you exactly mean when you say that your program is connected to notepad? Do you run the program and then you open myscore.txt in notepad?
Yes.
Does the name that you enter contain any special character or just plain ASCII?
I clicked the unicode controls etc.
Where? Notepad does not support unicode as far as I know (at least in XP it didn't).
I mean I clicked unicode control character on my notepad. I saved it as ANSI (?)
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;
}
Last edited on
It still question mark. But thanks a lot :)
Topic archived. No new replies allowed.