Help with the text based adventure

I am doing the text-based adventure project and am stuck. I want the player to just type start then the game begins. After this is where I planned on putting in my story and choices. I will paste the code here. Can someone tell me what I am doing wrong. I am not getting any errors. But after I type in start it just repeats the phase Type Start to Begin Adventure?


int main () {

std :: cout << “Welcome to A NIGHT AT THE ARCADE\n”;

std :: cout << “A text base adventure\n”;

std :: cout << “Written By: F M\n”;

char start;

for (int i = 0; i < 3 && start != ‘A’ ; i++) {

std::cout << “Type Start to Begin the Adventure\n”;

std::cin >> start;


switch (start) {

case ‘A’:

std::cout << “Game start\n”;




Hello, and welcome to the forums!

Try running your code again but type A instead of Start

Right now you’re storing the response in a char, so it will be limited to one character. In your for loop condition, you continue the loop if i is less than 3 and start doesn’t equal A. This means that if it does equal A then it will continue with your code that comes after the for loop.


Thank you, thank you, thank you. That worked. Now I just need to switch it so that I type start instead of A. So do I switch A doesn’t equal start will start be what I type of is there more I need to do?

There is more you’ll need to do.

Your variable named start has a type of char right now, and you’re using it to store the user’s response. It will only ever be able to hold one character (which basically means one letter for your purposes). Data types are very important in C++. Take a look at this article from earlier in the course called Basic Data Types for a refresher

Okay, I think I understand now. I will fix this and make this code work hopefully. Thank you for the help, and I will refresh myself on that article again.

You’re welcome. I’ll definitely try out your game if you post it in the project thread when you’re done :smiley:

Sure it will be a little while. Now that I can make the cofe work I can work on my story. May be a little while before I have it ready. I’ll let you know when it’s ready to play. Thank you again.