std::cout formatting

Hi, I was searching for a way to make whole words jump to the other line when using std::cout, but couldn't find anything useful. This is what my std::cout line looks like:

 
std::cout << "To use a randomly generated key enter 1, to read a key from 'Input\\Key input encryption.txt' enter 2: ";


This is what my output looks like:

1
2
To use a randomly generated key enter 1, to read a key from 'Input\Key input enc
ryption.txt' enter 2:


And I want the output to look something like this:

1
2
To use a randomly generated key enter 1, to read a key from 'Input\Key input
encryption.txt' enter 2:


Is there a way of doing this dynamically at runtime so I don't have to put a ton of spaces or something and it works for all sizes of consoles? Thanks!
It is not possible using only standard C++. cout is just a stream of characters. How the characters will be displayed depends on the program that receives the output.
Last edited on
Try this:

 
std::cout << "To use a randomly generated key enter 1, to read a key from 'Input\\Key\ninput encryption.txt' enter 2: ";
Last edited on
@Peter87
Thanks for the answer!

@loushizan
Is there a way of doing this dynamically at runtime so I don't have to put a ton of spaces or something and it works for all sizes of consoles?
You gave me the exact solution I was trying to get rid of...
Topic archived. No new replies allowed.