Testing a field made capital

Here's what I"m trying to do. I want to have the user input a letter, y OR n. I then want to put a 'tolower' statement in there so if the user puts in a Y or N it will automatically be made a lowercase letter. Then, it will be tested with an "if, else" ladder. Kind of like:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
...
error:
cout<< "Again? y=Yes/n=No";
cin>> yesNo;

tolower (yesNO);

if (yesNo == 'y')
    goto start;
         else if (yesNo == 'n')
              goto end;
              else
                   goto error;
end:
return (0);
}


The idea, as I said, is if the user enters a capital letter instead of a lowercase one, it'll still work. Any way to do it using the tolower () function? If not, there's always:

1
2
3

if (yesNo == 'y' || yesNo == 'Y')


Just curious how you would do it. Thank you.
Did you read the reference on tolower()?
I have. I understand that it has to go in some sort of loop, either for() or while(). I'm just having problems making it work. I either get an error when I have an asterix next to the variable name, or it'll put an extra space in there. Then when I go to test it in the if (), it keeps going to error. It may be that I'm trying to do it on only 1 character instead of a string. I really don't know though. I lack the experience in programming to make the absolute judgement call. I worked with this for about 3 hours last night trying to make it do what I wanted it to do, but no luck. The other thing I was looking at trying to do was test if an entry was a number or a character. All of this is with data integrity in mind, preventing Garbage in Garbage out.
I'll just give you a couple examples of proper usage:
1
2
3
4
5
std::cout <<tolower('Y')<<std::endl<<tolower('y')<<std::endl;
char a='Y',b='y';
a=tolower(a);
b=tolower(b);
std::cout <<a<<std::endl<<b<<std::endl;
Thank you so much for that example. The ones that I had all seen usually involved some kind of loop as I mentioned in my previous post. I think the problem was I was overthinking it, and didn't quite understand the examples. In fact, I think that's a better example than most that I've seen.
Well, if you're converting a string, you do need a loop. tolower() only takes a single character and returns a single character.
But your yesNo isn't a string. It's a character.
See, that's where I was going wrong. I was seeing examples of strings, not characters. Thank you for clearing that up for me.
Topic archived. No new replies allowed.