Jump to content
  • Advertisement
Sign in to follow this  
Scavenger23

cout location

This topic is 4832 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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++?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Ascii Table

Look at the bottom, say you want character 186, using char test = static_cast(186); std::cout <

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!