Q:

Placing Printed text in the same line as text before it

I'm currently making a basic program design to behave somewhat like a chell. The code is here:
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <Windows.h>
#include <Stdio.h>
#include <string>

using namespace std;

main()
{
    SetConsoleTextAttribute (GetStdHandle(STD_OUTPUT_HANDLE),10);
    std::string name;
    std::string pass;
    std::string msg;
    int x = 1;
    srand(time(0));
    cout << "Booting up system..." << endl;
    cout << "Serial Code: " << (rand()%1000) << "." << endl;
    cout << "Username: ";
    std::getline(std::cin, name);
    cout << "Password: ";
    std::getline(std::cin, pass);
    cout << "" << endl;
    while (true)
    {
        cout<<x<<": ";
        std::getline(std::cin, msg);
        x += 1;

        if (msg == "Hello!"){
        cout << "Hi!" << endl;
        }

        if (msg == ""){
        cout << "[No Text Inserted]" << endl;
    }
    system ("pause");
}

And, if no text is input it displays:
1:
[No Text Inserted]

How do I get this output?
1: [No Text Inserted]

Thank you in advance!
-DJ

A:

In your if statements, store the string into a variable and print out in the end. Also if you're comparing the same variable, I recommend using if else statements. It makes it more readable. So: 
string output;
if (msg == "Hello!)
{
    output = "Hi!";
} 
else if (msg == "")
{
    output = "[No Text Inserted]";
}
output = x.str() + ": " + output;

cout << output << endl;

Try that out and let me know if that works. 

