We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
hi how can you do a case insensitive string compare ? i'm using uvision3 , c51 version 8. the string.h don't know stricmp or strlwr. can i compile my own function ?
thanks gamba
Well done for using the correct tags to post your source code, but is that really how you lay it out?
Your indenting is quite bizarre! Have you used TABs? Don't use TABs, use spaces - TABs are entirely unreliable!
void lwrbuffer(checkbody) { int i; char *lwrtext; char *lowertextBody; i=0; for (;i <= strlen(checkbody);i++) { checkbody[i] = (checkbody[i]>='a' && checkbody[i]<='z') ? checkbody[i]-('a'-'A') : checkbody[i]; lowertextBody[i] = checkbody[i]; } strcpy (lwrtext,lowertextBody); return (lwrtext) ; }
You haven't defined the type of the parameter to lwrbuffer - 'C' will make an assumption, but it isn't what you want;
Why do you initialise i to zero in a separate statement outside the for loop?
You are converting each element of the checkbody array in-place - there is no need for all the messing about with copying to lowertextBody and lwrtext;
You are treating lowertextBody and lwrtext as if they were arrays - but they are just pointers;
You are returning a value in a void function.
Note that this is all standard 'C' - nothing specific to Keil nor the 8051 here!