Y/N Question

How I can make the program react when someone press Y or N? I should use #define *Letter* (hexa code) ? If yes, what are their hex values?
Last edited on
use cin and if statements if thats all you need, its alot simpler than what uve got
Last edited on
You mean something like this: if (choice == "Y")?
yea
I tried use that, but I did get this error:
C:\Codes\C++\C++ Projects\YN.c|10|error: ISO C++ forbids comparison between pointer and integer|
C:\Codes\C++\C++ Projects\YN.c|12|error: ISO C++ forbids comparison between pointer and integer|

This is the code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include  <iostream>

using namespace std;

int main()
{
   char choice;
   cout << "Press Y or N";
   cin >> choice;
   if (choice == "y")
       cout << "You pressed Y!";
   else if(choice == "n")
       cout << "You pressed N!";
   else
       cout << "...";
   cin.get();
}
Last edited on
"Y" is an array of char
'Y' is a char
choice is a char

Hope this helps.
Thanks!!!
Topic archived. No new replies allowed.