Subj : Re: string comparison To : borland.public.cpp.borlandcpp From : "MarvinAvery" Date : Mon Nov 24 2003 09:47 am "Base8" wrote in message news:3fc20683$1@newsgroups.borland.com... > Is there a simple way to do this? Any help appreciated. My intention is to > look at the first character of a passed string and verify that it contains > either an upper or lower case alpha ( >= a && <= z ) and ( >= A && <= Z ). > So, I figure I'd do a case insensitive comparison on the string and simply > test for zero (i.e. below). Well, no dice. I'm sure I've seen this, I just > can't put my fingers on it. > > > > newstring = new char[ sizeof(passedstring + 1 )] ; > assert( newstring != 0 ) ; > if(strlen(passedstring) >= 5 && strlen(passedstring) <= 8 ) > { strcpy(newstring, passedstring) ; > return 0 ; } > if( strncmpi(passedstring,(>="a" & <="z"),1)==0 ) <-------here > { return 0 ; } > else return -1 ; > > How about: if (isalpha(*passedstring)) return 0; --------------------------------- Marvin Avery marvin.avery@hrdc-drhc.gc.ca .