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!