Subj : Re: string comparison To : borland.public.cpp.borlandcpp From : maeder@glue.ch (Thomas Maeder [TeamB]) Date : Mon Nov 24 2003 09:31 pm "Base8" writes: > Is there a simple way to do this? Assuming that passedstring points to a zero terminated string, this will do what you are looking for. unsigned char const c(passedstring[0]); return std::isalpha(c) ? 0 : -1; std::isalpha is declared in the Standard header . It takes an argument of type int, which has to be either equal to EOF or have an unsigned char value. I returns a value !=0 if c represents a letter in the encoding used by the program. I don't understand the remainder of your code, and others have already pointed out errors in it. The following problem hasn't: > newstring = new char[ sizeof(passedstring + 1 )] ; > assert( newstring != 0 ) ; This test is moot. This new expression will *never* evaluate to 0. If the allocation request can't be served, the new expression causes an exception of type std::bad_alloc to be thrown. Do not rely on the letters being encoded contiguously, i.e. 'a'<=passedstring[0] && passedstring[0]<='z' || 'A'<=passedstring[0] && passedstring[0]<='Z' is *not* a good idea. First because you can't even portably assume that this will catch all the letters from 'a' to 'z', and second because you'll very probably miss the other letters (Umlauts, accented letters etc.). .