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++
ASCII number converter?
Moderator: Coders of Rage
- ibly31
- 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?
Website/Tumblr
My Projects
The best thing about UDP jokes is that I don’t care if you get them or not.
- Ginto8
- ES Beta Backer
- Posts: 1064
- Joined: Tue Jan 06, 2009 4:12 pm
- Programming Language of Choice: C/C++, Java
Re: ASCII number converter?
No need to convert. If you output it into a text file, like this:
then you can read it like this:
Code: Select all
ofstream write("level.txt");
int x, y;
// do stuff with x and y
write << x << " " << y;
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.
- ibly31
- 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?
I know, it should be easy but the library I'm using(darkGDK) won't let me use any other standard headers like ofstream...
Website/Tumblr
My Projects
The best thing about UDP jokes is that I don’t care if you get them or not.
- Ginto8
- ES Beta Backer
- Posts: 1064
- Joined: Tue Jan 06, 2009 4:12 pm
- Programming Language of Choice: C/C++, Java
Re: ASCII number converter?
o.0'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...
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.
- ibly31
- 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?
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;
}
int main(){
return 0;
}
but no its like
int main(system::event main.load, ^,^ &even::args){
return 0;
}
Website/Tumblr
My Projects
The best thing about UDP jokes is that I don’t care if you get them or not.
- Ginto8
- ES Beta Backer
- Posts: 1064
- Joined: Tue Jan 06, 2009 4:12 pm
- Programming Language of Choice: C/C++, Java
Re: ASCII number converter?
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.
- MarauderIIC
- Respected Programmer
- Posts: 3406
- Joined: Sat Jul 10, 2004 3:05 pm
- Location: Maryland, USA
Re: ASCII number converter?
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.
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.