Terminal input for players

How did you find working with cin? Do you run into any issues with it?

cin and cout is not something we will be doing a lot when we switch over to Unreal. But I wanted to give you an idea of some of the issues we can run into when we work with it and when it fails.

Later on, we’ll be covering how to fix any potential issues we may run into when it fails.

I’ve found that my only real problem is that sometimes I forget to put a space between each number in the guess and then press enter to find that I’ve messed up.

I often forget to include std:: . In my previous attempts to learn to code I’m so used to including the standard namespace at the top! But I understand we do it this way to avoid possible namespace conflicts

cin is a very useful tool. Concerning the coursework, no I had no problems with the code. I did have an issue when I was doing my own thing outside the coursework. I have some prior C and C++ experience and have put a lot of the code into their own functions. When I made a function for when you guess the wrong answer for the code, there was an issue with getting backslash () to print. A simple google and I discovered that in order for a backslash () to be printed, you must put two backslashes together inside the quotations (\). This tells the compiler to print the backslash ().

1 Like

I’m not quite understand, mani() returns 0, why it returns the number that you putted in? As in python, def returns the variable that follow the return keywords.

cin is incredibly confusing to me–I don’t quite understand why it does what it does but I’m glad it works X3 I might rewatch this lesson a few times.

image

1 Like

image

Not really sure why mine is outputting strange values.

***Never mind. While I don’t yet understand why it caused such a large value to be returned, I have two:
std::cin>> GuessB;'s in a row

Here’s what the output of my game looks like so far…I’m in to fantasy and been playing a lot of Diablo III lol

Great course so far! I forget to add “;” at the end of statements often so I’m learning to watch the errors when compiling, sometimes it takes me a minute to find what I did wrong but I’m glad for the little mistakes because it’s helping me troubleshoot. :stuck_out_tongue_closed_eyes:

There’s no problems related to cin with the exception that I had to turn off my antivirus for cin to work on my tripleX. I added my own story onto my game and this is what it looks like so far. The story is an inmate that attempts to escape his or her own cell using the riddle that the inmate find around his or her cell.

hi
i have entered the values but the number is different as below:

Capture

Hi Gavin

For some reason, as soon as I compiled the original user input statement (std::guessA etc) as soon as I’d attempt to execute it there would be a failure message (system could not execute program) and McAffee warning me I’d been attacked by a virus each time I tried to fix it and execute it again. Has this happened before?

Getting into a spooky situation xd

And this is my code so far … :stuck_out_tongue:

This is my code so far:

this is my code :

Sorry, I am having a new issue. I added the “Guess” variables, but now for some reason, my .CPP file is NOT exiting after user input is entered. What did I do wrong here?

Privacy & Terms