Spardan
03-06-2003, 12:27 PM
I've just started teaching myself C++, and have put together a simple denary to binary convertor.
The app simply gets the modular of each division by 2 of the target denary and following results, and then pulls them out of an array backwards.
I'm fairly proficient in Object Pascal (Via Delphi) and want to know if there is a way to validate user's input in C++ like the conversion from string to int or real via the 'val' procedure.
For example, if a user enters a number too large or enters non-numeric characters, I'd like to be able to catch that error, and display a relevant message.
Also, just as an Idle Point of Curiosity, can anyone tell me why any number to the power of zero = 1? I've got some ideas but I'm not convinced and I seem to recall that it may all be based on a miscalculation...
Any help with either is, as always, greatly appreciated
Cheers,
Spardan
The app simply gets the modular of each division by 2 of the target denary and following results, and then pulls them out of an array backwards.
I'm fairly proficient in Object Pascal (Via Delphi) and want to know if there is a way to validate user's input in C++ like the conversion from string to int or real via the 'val' procedure.
For example, if a user enters a number too large or enters non-numeric characters, I'd like to be able to catch that error, and display a relevant message.
Also, just as an Idle Point of Curiosity, can anyone tell me why any number to the power of zero = 1? I've got some ideas but I'm not convinced and I seem to recall that it may all be based on a miscalculation...
Any help with either is, as always, greatly appreciated
Cheers,
Spardan