Sign in to follow this  
phil05

Need some advice on this code

Recommended Posts

I click on new game, and a character generation dialog pops up, so I enter my information and forget to enter my age on it. I press the "done" button and it should alert saying that my age has not been defined. Apparently it is not doing that. Any idea why?
// bAge = buffer for Age (char array)
// pcAge = unsigned short int that the buffer converts into.
unsigned short int pcAge = 0;
char bName[30];
char bAge[15];
	
// Pressing "Done" and does an error check.
						SendDlgItemMessage(dWnd, IDC_PCAGE, WM_GETTEXT, sizeof(bAge), (LPARAM)bAge);
							pcAge = unsigned short int(bAge);	
							
							/* Error Check -> If pcAge is empty, alert user and return TRUE */
							if (pcAge < 1)
							{
								MessageBox(NULL, "Please Enter Your Age", "Error", MB_OK);
								return TRUE;
							}


Share this post


Link to post
Share on other sites
Happy birthday ;-)


#include <sstream>
#include <iostream>

int main() {

char age[] = { '1', '5', '0', '\0' };

std::stringstream ss(age);

int a = 0;

ss >> a;

std::cout << a << '\n';

return 0;
}





Your 150 today

[Edited by - snk_kid on August 5, 2004 2:41:01 PM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this