I'm making a text based adventure game in C++. Sometimes it asks you to enter an integer, and if you enter a letter the game will get screwed up... so I was looking for a way to fix this and I found this:
Code:
int integer()
{ char inputdata[100];
cin >> inputdata;
return atoi(inputdata);
}
The only problem with this is that if you enter a character instead of a number, it will interpret it as 0, I just want it to say. "Invalid character" or something and ask you to input an actual number... anyway I can fix this?
I was also wondering how I could make it save your game. All I need it to do is like save a bunch of variables to a text document, and then beable to read them when you open the game again. Can anyone help me??



LinkBack URL
About LinkBacks


