cout location

Started by
13 comments, last by Zahlman 18 years, 7 months ago
When drawing to the console screen, how would I set cout to start at a specific location, without using a bunch of newlines and spaces? I want to draw at a single spot without overwriting anything else on the screen.
----------------------------Project Legend
Advertisement
i think the funtion you want is SetCursorPosition(),

google it, and ask more if you have any trouble
the mountains quake, and a little mouse pops out
std::cout is a stream. A file-like channel. C and C++ only know how to manipulate files. They do not know the file really is a console. In fact, it might not, if you have redirected it when starting the program by writing myprogram > outputfile. If you do that, all the std::cout writes wil end up in the "outputfile" file.

If you want to manipulate a console, you need to rely on whatever platform-specific API you are using like SetCursorPosition, as micro_mus suggested, not on C++ library functions.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
What about <iomanip>? Or am I misunderstanding his question?
Thanks, that's what I needed. Well, I saw some characters in basic that lined up and didn't have gaps, (double lines) how would I display those in C++?
----------------------------Project Legend
Quote:Original post by ukdeveloper
What about <iomanip>? Or am I misunderstanding his question?


<iomanip> contains components that let you control formatting, like how many decimal places do you want to display when printing a floating point number or whether you want your integers printed in decimal or hexadecimal format. That kind of things. While it can let you pad printed fields to a given width, it still doesn't know - or care - about the nature of the device it is writing to.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Quote:Original post by Scavenger23
Thanks, that's what I needed. Well, I saw some characters in basic that lined up and didn't have gaps, (double lines) how would I display those in C++?



what do you mean by that? if you mean move the characters according to pixels, thats not possible through the console. The console screen will be split into character spaces not pixels. i think the default size for a dos(ugh) window is 80x25.

the mountains quake, and a little mouse pops out
This is what I mean. How can I use that character set? I want to use the double line symbols near the bottom of the set.
----------------------------Project Legend
Ascii Table

Look at the bottom, say you want character 186, using char test = static_cast(186); std::cout <
Is "Ascii Table" supposed to be a link? And the character 186 thing, could you break it up into multiple lines, it doesn't quite make sense.
----------------------------Project Legend

This topic is closed to new replies.

Advertisement