sads
sads

Reputation: 11

C++ cin: don't show the newline

If I get some value by using getline( cin, myStr ); a newline is printed after the information the user entered - logically as he pressed enter:

Please enter something: ABC <enter => \n>
This text is printed out by the program and should be in the same line as before

I'm using MSVC 2010 and build a simple console app using iostream and string as main libraries.

Upvotes: 1

Views: 1272

Answers (2)

rlbond
rlbond

Reputation: 67867

You can't do this using just standard C++. I'd recommend looking at PDCurses, which is a Windows-compatible replacement of NCurses.

Upvotes: 1

anon
anon

Reputation:

You can't - the newline processing isn't controlled by the C++ program. What you can do is use the Windows console APIs to reposition the cursor after the input. Or use those APIs to write your own version of getline().

Upvotes: 1

Related Questions