noisy cat
noisy cat

Reputation: 3065

Standard console output without nextline

I would like to write 80 (standard conole width) characters in one line without the cursor go to next line. It is only problem when I want to print 80 characters in the last line of console. It cases scrolling that I dont want.

Take a look:

enter image description here

I dont want the newline. any way to do this? :/ Im on Windows, DEV-C++, using WinApi for colors and moving the cursor (the window resize too).

Thanx for any answers.

Upvotes: 1

Views: 690

Answers (5)

bames53
bames53

Reputation: 88235

Instead of using standard output functions use the Windows Console API to set the cursor position and draw characters. Specifically, take a look at WriteConsoleOutput.

MSDN Console API Docs

Upvotes: 2

ejgottl
ejgottl

Reputation: 2829

filter the output either in the originating program or with another program through a pipe. When you have outputted too many characters on a single line, do whatever you like (i.e., drop characters, overwrite, etc....).

Upvotes: 0

Desmond Hume
Desmond Hume

Reputation: 8627

For the system-critical console window, the cursor should always stay visible, and the only way for it to do so after you've reached the max number of chars in a line, is to pop up on the next visible line (without actually making any new lines).

Upvotes: 0

Soroosh Bateni
Soroosh Bateni

Reputation: 897

through one or two "\b" at the end it moves the cursor back.

Upvotes: 0

Naftali
Naftali

Reputation: 146360

The only reason why you are on a new line is because the console is not big enought to support the eighty stars.

So it pushed the cursor to the next line.

Upvotes: 1

Related Questions