How to make it so it shows one line of text and then you click enter and then the next line of text appears

Hey Guys
How do I make it so the text comes after you click enter (So it shows one line of text and then you click enter and then the next line of text appears)

Here is my code (Doesn't work properly though yet)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include <iostream>
#include <string>


using namespace std;

bool running = 1;

int userInput = 0;

int playerInfo[2];

void titleFunc();

int playerLocation = 0;

int main()
{
    void titleFunc(); {
    cout << "\t\t\t\t---Xeon---\n\n\n";
    cout << "\t\t\t\t   1: Play\n";

    cin >> userInput;
    if(userInput == 1) {
            void newGameFunc(); {
            cout << "Welcome to Xeon!\nAn unexlored world full of adventurous paths and dangerous creatures!\n\n\n";
            cout << "I am Zolo... The DragonBorn!\n\n\n";
            cout << "Since you are a new comer to Xeon...\nCould you please tell me a little about yourself?\n\n";
            cout << "Are you a boy or a girl?\n 1: Boy\n 2: Girl\n";
            cin >> userInput;
            playerInfo[0] = userInput;

            cout << "And what kind of person are you?\n 1: Warrior\n 2: Archer\n 3: Thief\n 4: Scout\n 5: Mist\n";

    cin >> userInput;

    playerInfo[1] = userInput;

    cout << "You suddenly feel a gentle breeze pushing you but you ignore it\n\n\n";

    cout << "I thought I senced that in you! So now... Wait... Where are you going... What is happening!!\n\n\n";


    cout << "You suddenly feel the breeze turning into a violent wind.\nYou look down at your hands but they start disapearing...\nEverything around you is becoming blury...\nYou suddenly feel very dizzy and your vision starts to fade...\nAnd then... Everything turns Black!\n\n\n";

    playerLocation = 1;


            }

    }
    else {
        running = 0;
    }
     return 0;
}

    while (running) {
            if(playerLocation == 1) {

    cout << "You look around and you are in a wild jungle.\n You walk for a bit and you find yourself at the edge of a cliff.\n Eveything looks amazing and tropical around you!\n You look down and there is a sky blue lake.\n";
    cout << "Do you jump down or turn back?\n 1: Jump\n 2: Turn around and walk away\n";

    cin >> userInput;

    if(userInput == 1) playerLocation = 2;

    else if(userInput == 2) playerLocation = 3;

}
  if(playerLocation == 2) {

    cout << "You jumped down and landed with a big splash in the crystal water\n While you are in the water you see a small cave\n";
    cout << "Do you enter the cave or do rise to the top of the water and walk away?\n 1: Enter the cave\n 2: Rise out of the water and walk away";

    cin >> userInput;

    if(userInput == 1) playerLocation = 4;

    else if(userInput == 2) playerLocation = 5;

}
  if(playerLocation == 3) {

    cout << "You walk away from the cliff and find yourself walking down a hill.\nYou suddenly stop and look behind you where you see a lion starting to chase you\nTo your right there is a shallow hole you could jump down that the lion couldnt fit\n OR you could run straight ahead to some vines hanging down infront of another cliff\n\n";
    cout << "Do you go and hide in the hole or do you jump and swing on the vines?";

    cin >> userInput;

    if(userInput == 1) playerLocation = 6;

    else if(userInput == 2) playerLocation = 5;

}

    }
    return 0;
}


Please help me!
where does that problem occure?

maybe ignore is what you're looking for?

http://www.cplusplus.com/reference/istream/istream/ignore/
Create the following function, and call when needed.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//wait.cpp

//include for _getch()
#include <conio.h>

PressEnterToContinue()
{
	std::cout << "Press [ ENTER ] to continue...";   

	char key = '\0';

	// 13 in ascii for enter. Look below.
	while( key != 13 )
	{
		key = _getch();
	}
}


You can find the ascii values for keys here:
http://www.asciitable.com/

Now when you want to pause your program, just call that function.

Last edited on
Topic archived. No new replies allowed.