Subj : Re: string comparison To : borland.public.cpp.borlandcpp From : "Sebastian Ledesma" Date : Tue Nov 25 2003 11:54 am I will prefer: newstring = new char[strlen(passed)+1]; Also, sometimes i prefer to use: set_new_handler(0); this ensures that a fail in the allocation didnt throw a exception, instead it returns NULL (as lot of code expect). Saludos Sebastian "Base8" escribió en el mensaje news:3fc29913$1@newsgroups.borland.com... > Thanks to all who responded. My thoughts on the assert( newstring != 0 ) ; > are as follows (please correct me > if I have an incorrect understanding) :-). The assert is used during > testing and debugging to verify that memory > is being allocated appropriately for the requested data type. It gets taken > out at compile time with a #define NDEBUG > which causes the assertions to be ignored. Am I incorrect here? BTW, I > knew it was simple, I used the isalpha as below. > > int StrPass::Passed(char *passed) > { > newstring = new char[ sizeof(passed + 1 )] ; > assert( newstring != 0 ) ; > if(strlen(passed) >= 5 && strlen(passed) <= 8 ) > if( isalpha(passed[0] )) > { strcpy(newstring, passed) ; > return 0 ; } > else return -1 ; > } > .