I'm pretty new to C++, being in the freshman programming course. And I've searched through the FAQs and I couldn't find what I needed. So please bear with me.
Basically, what I'm looking to do is convert a specific number on a character array to an integer. I'm working on a battle program, and I'm using "character cards" if you will. They look like this:
Before the battle I set a blank char array to whichever opponent will be in that battle. Call it blank.Code:char BANDIT[#][#]={ {" Name |HP:0010 " }, (hp=100) {" Graphic |MP:##### "}, {" Graphic |POW:#####"}, {" Graphic |INT:##### "}, {" Graphic |HPP:##### "}, {" Graphic |SPD:##### "}, {" Graphic |EXP:##### "}, {" |CRED:#####"}};
I then, during the battle, want to pull blank[#][#] and set it to an int. Say I want to get the enemy's Hitpoints. I want to pull the first number after Hp: and multiply it by 10,000, the second and multiply it by 1,000, the third by 100 and the fourth by 10, then add them to get the enemy's HP.
However, I'm not sure of a way to do that. I get the name and graphic to show separate from the rest, but when I try to set the the numbers as an integer, it comes up with some absurd number that I have no idea where it came from. Again, I'm new to coding and inexperienced, so bear with me on this. Any help would be very much appreciated.



LinkBack URL
About LinkBacks


