Page 1 of 1

ASCII number converter?

Posted: Thu Mar 05, 2009 9:08 pm
by ibly31
I'm making a tile map editor, and I need to write to a txt file. I have everything set, but I don't know how to convert numbers greater than or equal to 10... 1-9 you just add 816 and you have the code, but for 10, I'd be writing a word to the file; instead of a byte.

I've been using dbWriteByte(file,asciicode);

And it needs to check if it's greater than ten and instead do

dbWriteWord(file, two byte ascii value)

I don't know what to do... Help?

EDIT: if you guys are like "WTF is he talking about?", please ask questions. I'm using C++

Re: ASCII number converter?

Posted: Fri Mar 06, 2009 2:08 pm
by Ginto8
No need to convert. If you output it into a text file, like this:

Code: Select all

ofstream write("level.txt");

int x, y;

// do stuff with x and y

write << x << " " << y;
then you can read it like this:

Code: Select all

ifstream read("level.txt");

int x, y;

read >> x >> y;

// do stuff with x and y

Re: ASCII number converter?

Posted: Fri Mar 06, 2009 2:47 pm
by ibly31
I know, it should be easy but the library I'm using(darkGDK) won't let me use any other standard headers like ofstream...

Re: ASCII number converter?

Posted: Fri Mar 06, 2009 4:16 pm
by Ginto8
ibly31 wrote:I know, it should be easy but the library I'm using(darkGDK) won't let me use any other standard headers like ofstream...
o.0' :shock2: :shock2: :shock2: :shock: :shock: :shock:
typical Microsoft...

and btw the header is fstream.

Re: ASCII number converter?

Posted: Fri Mar 06, 2009 5:22 pm
by ibly31
Yeah, I just wanted a regular CMD prompt program, but microsoft overloads it with shit... like

int main(){
return 0;
}

but no its like

int main(system::event main.load, ^,^ &even::args){

return 0;
}

Re: ASCII number converter?

Posted: Fri Mar 06, 2009 6:53 pm
by Ginto8
do you need to use darkGDK? just wondering ;)

Re: ASCII number converter?

Posted: Sat Mar 07, 2009 12:56 pm
by MarauderIIC
Sounds like it's DarkGDK's fault, not Microsoft's.
Also, sorry, can't help you with DarkGDK. Look for DarkGDK I/O equivalents in the docs, I suppose.