How can I get the real number?

A

Allen Maki

//Hi everybody,

//I need your help.
//If I run this program I will get an 'L'.
//But I want to get the real number (76).
//Can anybody tell me what to do?

#include "stdafx.h"
#using <mscorlib.dll>
using namespace System;
using namespace System::IO;
int _tmain()
{
FileStream* fs = new FileStream(S"bar.txt", FileMode::Create);
BinaryWriter* bw = new BinaryWriter(fs);
bw->Write(76);
return 0;
}
 
G

Guest

//Hi everybody,
//I need your help.
//If I run this program I will get an 'L'.
//But I want to get the real number (76).
//Can anybody tell me what to do?

#include "stdafx.h"
#using <mscorlib.dll>
using namespace System;
using namespace System::IO;
int _tmain()
{
FileStream* fs = new FileStream(S"bar.txt", FileMode::Create);
BinaryWriter* bw = new BinaryWriter(fs);
bw->Write(76);
return 0;
}

Hi,
'L' is the ASCII symbol with numeric code 76.
You see this behavior because you write a binary file.
If you want to write the number 76 as text, use the TextWriter class instead
of the BinaryWriter class.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top