#include <iostream>
using namespace std;
char myChar_1 = 'a';
char myChar_2 = 'b';
char checkChar(char myChar_1,char myChar_2){
if ((isupper(myChar_1) && isupper(myChar_2)) || (islower(myChar_1) && islower(myChar_2))) {
return true;
}
else{
return false;
}
}
int main()
{
cout << checkChar(myChar_1, myChar_2);
}
The output is an upside-down question mark. Would be great if someone could tell me what I’m doing wrong. Niko
Your return type should be
bool. You’re returningtrueandfalseaschars and then outputting that character. When converting fromboolto an integral type,trueis converted to 1 andfalseis converted to 0. So you’re printing outchars with values of 0 or 1.