mardi 4 août 2015

Using right and left justification on the same line and replacing that line in the console

This is my first question on here, so I hope I'm being clear enough. I'm finishing up a little programming project for a class at the moment. I'm done with all of the actual requirements for the project, but I'd really like to make it look nicely formatted now.

How can I send two separate statements of output, from say, two different classes, to the same line on the console with one being left justified and one being right justified. At the moment when I attempt to do this it smushes the two together with both being on the left side. I also need to delete and update the same line of code during this process as well if it is to end up looking how I want it.

Here is as far as I got fiddling around with some test code:

for (int x = 0; x < 10; ++x)
{
    cout << '\r' << left << "stuff on the left" << right << "stuff on the right" << flush;
    this_thread::sleep_for(chrono::seconds(1));
}

Any help or suggestions would be greatly appreciated!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire