Home > Net >  How To Properly Display My Inputted Variables On The Terminal Following Receiving The Input On C
How To Properly Display My Inputted Variables On The Terminal Following Receiving The Input On C

Time:12-19

I'm trying to run a simple line of code here where I get three different integers provided by the user in the terminal under the CamelCased variable declarations: GuessA, GuessB, And GuessC.

int GuessA, GuessB, GuessC;
    std::cin >> GuessA;
    std::cin >> GuessB;
    std::cin >> GuessB;
    std::cout << "You entered: " << GuessA << GuessB << GuessC;

My output looks like this in the terminal

If I enter for example for my GuessA, GuessB, And GuessC Input:

1
2
3

My Output is::

you entered: 1313630328

Why is it not displaying:

123

Thanks in advance.

CodePudding user response:

Try replacing

std::cin >> GuessA;
std::cin >> GuessB;
std::cin >> GuessB;

with

std::cin >> GuessA >> GuessB >> GuessC;

CodePudding user response:

Check you fourth line:

std::cin >> GuessB;

Do you mean GuessC here?


Since you cin >> GuessB twice, GuessB now store the last value you input, 3. And GuessC was uninitialized, which can have any value, which is why you are seeing 13630328 for it.

  • Related