Newbie C++ programmer again...

Alan Dayley ADayley@adtron.com
Fri, 18 Aug 2000 15:03:25 GMT


Check each character either at imput (I would do it then) or after you 
have the entire string.  In C or C++ a character variable is just a 
number based on the character set table (ASCII or something else).  You 
get the number of a character by using the single quote of the character. 
 Just check the value of the character kind of like this:

if ((char < '0') || (char > '9') || (char != '.'))
{
	/* not a character or decimal point, ask for correct input */
}
else
{
	/* input good, use it */
}

That is a rough skeleton and needs to be adapted to your program but try 
that.

Alan

>>>>>>>>>>>>>>>>>> Original Message <<<<<<<<<<<<<<<<<<

On 8/18/00, 12:31:00 AM, "Eric Samson" <airickjay@hotmail.com> wrote 
regarding Newbie C++ programmer again...:


> Ok, I have about gone nuts trying to figure this out...

> This is my assignment that I am having trouble with..

> It's a simple currency converter, the user enters a float which indicates
> how many US dollars they want to convert to a specified currency, in my 
case
> Deutchmarks...  That is the easy part, got it written no problem, simple
> math... An optional part of the assignment is to validate the user input 
and
> be sure it is a numeric value (float), and not an alpha charater, symbol,
> etc...  If they enter something that will not work, they are supposed to 
be
> prompted to try to enter the info again...  Preventing negative values is 
no
> problem with the <while (someinput < 0)> loop, but if they enter an alpha
> value, it enters an infinite loop.  I went to borders last night and my
> roommate and I (mostly because he is tired of hearing me whine about it)
> looked in a bunch of books for a solution, and didn't have any luck.  My
> instructor was no help either, he wasn't sure how to do it (he is a VB
> programmer teaching C++, go figure)...  This seems like something that
> should be painfully simple...  Is this something too complex for a 
beginning
> programmer?  I should think that it would be a basic part of programming,
> but I could be wrong...  I notice a few people on here saying they don't 
use
> C++ much, so what is the language of choice for programming in Linux?

> Thanks again,

> Eric
> ________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com


> _______________________________________________
> Plug-devel mailing list  -  Plug-devel@lists.PLUG.phoenix.az.us
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-devel