I don't know how to include lower case a-z or upper case A-Z in a if else statements
thanks in advance.
If oneChar between 'a' ... 'z' or 'A' ... 'Z', then returns
// true, else, returns false.
I don't know how to include lower case a-z or upper case A-Z in a if else statements
thanks in advance.
If oneChar between 'a' ... 'z' or 'A' ... 'Z', then returns
// true, else, returns false.
Take a look at some C string/character functions.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
ascii value of A-Z is 65 to 90
and a-z is 97 to 122
sample:
Code:char b = 'b'; if( b <= 65 && b >= 90 ) return true;
Originally Posted by rdave1and use it like thisCode:bool is_a_to_z( char c ) { return (( c >= 'a' && c <='z' ) || ( c >= 'A' && c <='Z' ) ); }
is that what you are looking for ?Code:char c; cin >> c; if ( ! is_a_to_z(c) ) { cout << "illegal chracter '" << c << "'" << endl; }
Kurt
Last edited by ZuK; 09-15-2005 at 09:43 AM.
Of course you all are assuming ASCII wish isn't required. Since it appears that you want to know if its an alphabetic character why not just use isalpha()?
And you are assuming english char-set. In other char-sets there are more char's for witch isalpha() would return true.Originally Posted by Thantos
On the other hand there are few questions on this board that can be answered without any assumptions.
Kurt
indeed indeedOriginally Posted by ThantosOriginally Posted by ZuK