Comparing a string (case sensitive)
I am trying to compare the string addPayType to all case sensitive possibilities. I have tried the strupr(), and a few other i have found on this board with 0% success rate. Here is my code snipit, Remember addPayType is string class. I did #include <string> and ctype.h in trying all the possiblilties found on this board. This is my first post so please forgive if im enter it incorrectly.
Code:
if(addPayType == "salary" || addPayType == "Salary" || addPayType == "SALARY")
Does strcmp() worry about the case of the letters in the string when comparing??
I accidentally posted new thread last time i trie to ask LOL
Thank you all for your help..
I went with the strcmp() option presented by master5001 and it works fine. this is what the snipit looks like now. Ty all
Code:
#include <cstring.h>
char temp[9];
cin >> addPayType;
strcpy(temp, addPayType.c_str());
strupr(temp);
if(strcmp(temp, "HOURLY") == 0)
{
// do stuff;
}
again i thank you for your help
as advised earlier i tried strcmp() then after reading al ittle farther i noticed the strcmpi() and now i see stricmp(). Which is the correct ver, or are they both correct. I used strcmpi() and it works fine.