ASCII number converter?

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
ibly31
Chaos Rift Junior
Chaos Rift Junior
Posts: 312
Joined: Thu Feb 19, 2009 8:47 pm
Current Project: Like... seven different ones
Favorite Gaming Platforms: Xbox 360, Gamecube
Programming Language of Choice: C++, ObjC
Location: New Jersey.

ASCII number converter?

Post 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++
Image
Twitter
Website/Tumblr
My Projects

The best thing about UDP jokes is that I don’t care if you get them or not.
User avatar
Ginto8
ES Beta Backer
ES Beta Backer
Posts: 1064
Joined: Tue Jan 06, 2009 4:12 pm
Programming Language of Choice: C/C++, Java

Re: ASCII number converter?

Post 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
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
User avatar
ibly31
Chaos Rift Junior
Chaos Rift Junior
Posts: 312
Joined: Thu Feb 19, 2009 8:47 pm
Current Project: Like... seven different ones
Favorite Gaming Platforms: Xbox 360, Gamecube
Programming Language of Choice: C++, ObjC
Location: New Jersey.

Re: ASCII number converter?

Post 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...
Image
Twitter
Website/Tumblr
My Projects

The best thing about UDP jokes is that I don’t care if you get them or not.
User avatar
Ginto8
ES Beta Backer
ES Beta Backer
Posts: 1064
Joined: Tue Jan 06, 2009 4:12 pm
Programming Language of Choice: C/C++, Java

Re: ASCII number converter?

Post 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.
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
User avatar
ibly31
Chaos Rift Junior
Chaos Rift Junior
Posts: 312
Joined: Thu Feb 19, 2009 8:47 pm
Current Project: Like... seven different ones
Favorite Gaming Platforms: Xbox 360, Gamecube
Programming Language of Choice: C++, ObjC
Location: New Jersey.

Re: ASCII number converter?

Post 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;
}
Image
Twitter
Website/Tumblr
My Projects

The best thing about UDP jokes is that I don’t care if you get them or not.
User avatar
Ginto8
ES Beta Backer
ES Beta Backer
Posts: 1064
Joined: Tue Jan 06, 2009 4:12 pm
Programming Language of Choice: C/C++, Java

Re: ASCII number converter?

Post by Ginto8 »

do you need to use darkGDK? just wondering ;)
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: ASCII number converter?

Post 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.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
Post Reply