Capitalization Error ?
how can i make this program to accept the answer like Y or Yes without putting this long code
1 2
|
(rerun == 'Y' || rerun == 'Yes' || rerun == 'yes' || rerun == 'yEs' || rerun == 'YeS')
|
Well you can use strcpi(str1,str2)==0 to compare 2 string, it will return 0 if str1 and str2 is match
Several things wrong with your snippet. First character constants can only have one character not the multiple you have in your code.
What type of variable is rerun? A char, C-string, std::string?
You can use toupper() or tolower() to convert the char to a known case then you only need to check it once.
1 2 3 4 5
|
char rerun;
...
if(toupper(rerun) == 'Y')
{
// Do something.
|
Topic archived. No new replies allowed.