Got a Problem :(

Got a Problem guys :( i try to make a something like a game,but i wanna to make:
When i press 2 the name of episode to be a diffrent :( because now whatever i press it do a same name and i don't know how to fix that :(

#include <iostream>
#include <string>



int main()
{
cout << "Wellcome\n\n";

cout << "Choose Episode (1-3): ";
if (cin.get() == '\n')
cout << "Good Job.\n";
else
cout << "Only (1-3).\n";

std::string name;
cin::name;

const std::string greeting = "The Episode - " + name + " - Dark Insomnia";

return 0;
}
1
2
3
4
5
int ep;
cin >> ep;
if( ep == 1 ) ...
else if( ep == 2 ) ...
else ...
is what you should be doing.
But When I Do this then i need to write a name to prints a down and when i write for example "ok" it says The Episode ok - Dark Insomnia how to do it to detect a name and do not need to write,i want a something like this:

Choose Episode (1-3):1
Dark Insomnia
The Episode - 1 - Dark Insomnia

that's what i want :( without pressing something after pressing 1 :(
Last edited on
I don't see your problem. "1" is all a user is supposed to enter, right? Then you just need to look up the name in an array and print it.
The Problem is that when i go into program and i must write a something after it prints a Dark Insomnia,like this:

Wellcome

Choose Episode (1-3):1
Dark Insomnia (and here must write something because it's not continue)

:(
I Wanna ask and something diffrent,How to make a detect press key like if "Press Enter to Continue..." and i press a space to not gontinue :?
that's what i want :( without pressing something after pressing 1 :(


You can't easily do that in console programs. The console is for IO streams. Console programs don't care what you type into the input device (your keyboard) until you stream it by pressing ENTER. You need to use event-based GUI packages to detect individual key presses.
Ok thanks :(
Topic archived. No new replies allowed.