Writing characters to a .txt file

Hi,

I'm trying to write a code that puts some characters into a text file. The characters are produced by a function, which as far as I can see works. So, I have an array of characters, and at the same time as I put one after another into the text file, I also print the character, to be sure that it's not writing something weird. However, that's still what's happening. That is, in my terminal window in which the characters are printed, I see the right things (i.e. legible stuff), but in the text file it's a completely different story (what looks almost like Greek letters, various symbols and boxes with four digits in them (like a tiny, boxed matrix) ).

Here's the code that I'm using to print and write into the text file:

1
2
3
4
5
6
7
8
9
10
11
12
    
char message[2000];
    translate(ciphered, myalpha, message);
    ofstream outputFile;
    outputFile.open("Message.txt");
      for(int p=0;p<100;p++)
      {
	cout << message[p] << endl;
	outputFile << message[p]<<endl;
      }
    outputFile.close();
}


So, the cout ... part works (see output below), but the text file looks different (see below below).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
o
*
u
g
r
$
l
a
o
c
M
l
%
Q
Y
Q
B
f
3
M
:
%
u
g
r
$
u
r
r
$
x
P
#
Q


[The meaning of these characters is not important. Nor is the format of this sort of stupid cout-ing.]

 
ਯ੣੯ਪੵ੧ੲਤ੬੡੯੣੍੬ਥੑਖ਼ੑੂ੦ਲ਼੍਺ਥੵ੧ੲਤੵੲੲਤ੸੐ਣੑਖ਼ੑ੯ੑਖ਼ੑ੫ਲ਼੟੯੺ੲੰ਱੯੣ੈ੢੬ਨੲ੔੣ਪ੧੶ਣ੺੺੣੡ੱ਺ਥ੔ੲ੺੪੶੭੣ਦਲ਼ੰ਀੯ੰ੫૱਀਀਀਀਀਀਀਀਀਀਀਀਀਀਀


[I hope the last symbols came out right -- they are weird]

I'm pretty new to this stuff, so I might be using a completely wrong method, I don't know. So, my question is: how can I get these roman alphabet + numbers and so on into my text file?

Thanks!
Is that all the characters you get from cout? Why are they less than 100?
@Peter87: Oh, sorry, I forgot to note that this is only part of the output. There is more, I just thought it would suffice to show the first third or so. Sorry about that.
Topic archived. No new replies allowed.