Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Mindar

Is there a function to set the cusor in a console app to the beginning?

This topic is 5674 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

Is there a function to set the cusor(the blinking line) in a console app back to the beginning? Please respond ASAP and thanks.

Share this post


Link to post
Share on other sites
Advertisement
Im not sure exactly which tutorial it is, but if you look over at www.gametutorials.com there are some nice tutorials about console programming which cover what you want. Check out the C++ tutorials section.

Share this post


Link to post
Share on other sites
don''t double post everybody hates it. Yes i''m sure there is a way to put the cursor back to the beginning of the line, it is an escape key, i think \g. if thats not then go try every letter.

Share this post


Link to post
Share on other sites
To go back letter by letter, you can use \b.

There must be other things you can do, though, but I''m not really that knowledgable. If you are using Windows, I think there is function, something like SetConsoleCursorPosition(), that might help - have a search at MSDN.

I''m not sure, as you did not say, whether or not you wanted the text outputted to the console to remain visible, but you could use system("cls"); to clear the screen, leaving the cursor at the top (in its original position).

:::: Lektrix ::::
[ Google || ACCU || BarrysWorld || E-Mail Me ]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
would gotoxy(1,1) work?

Share this post


Link to post
Share on other sites
Only in some versions of ? I believe. I don''t think it works in VC++ either. I could be wrong.

Share this post


Link to post
Share on other sites
I think the equivalent gotoxy() function for Windows'' command prompt is, as I mentioned earlier, SetConsoleCursorPosition(), or at least it is something that you can use. I looked on the net and found this code - seems to work fine:

  
void SetCursor(int row, int col)
{
col =- 1;
row =- 1;

COORD cursorcoords;
cursorcoords.X = col;
cursorcoords.Y = row;

SetConsoleCursorPosition(handle, cursorcoords);
}


:::: Lektrix ::::
[ Google || ACCU || BarrysWorld || E-Mail Me ]

Share this post


Link to post
Share on other sites

  • 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!