#include <iostream>
int main()
{
std::cout << "You wake up hanging upside down from your parachute, dangling about 15 feet" << std::endl << "in the air." << std::endl << std::endl;
std::cout << "In the distance you see a small cave below a cliff." << std::endl << std::endl;
std::cout << "What do you do?" << std::endl;
std::cout << "1) Scale the cliff" << std::endl;
std::cout << "2) Enter the cave" << std::endl;
}
How can i then check if 1 or 2 is pressed and make it print different things depending on which key is pressed?
If you, however, insist in using keypresses instead of regular inputs, you should try the popular NCurses library which is available on the internet, free of charge.
If you are on a Windows system, you might also try the (unpopular) conio.h library.
#include <iostream>
usingnamespace std;
int main (){
int choice;
cout << "What is your favorite number, 1 or 2?" << endl;
cin >> choice;
if (choice == 1) {
cout << "oh, so your favorite number is 1 ey!" << endl;
} ;
if (choice == 2){
cout << "so your favorite number is 2 eyy!" << endl;
}
system("pause");
return 0;
}
EDIT: Please no lectures on System("pause"); please. Not in the mood. lol, it's simple for illustration purposes