Advertisement

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

Started by February 06, 2003 06:22 PM
5 comments, last by Mindar 21 years, 9 months ago
Is there a function to set the cusor(the blinking line) in a console app back to the beginning? Please respond ASAP and thanks.
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.
Life is all about expression, so express yourself.
Advertisement
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.
~EODCyismARDEM
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 ]
[ Google || Start Here || ACCU || STL || Boost || MSDN || GotW || CUJ || MSVC++ Library Fixes || BarrysWorld || [email=lektrix@barrysworld.com]E-Mail Me[/email] ]
would gotoxy(1,1) work?
Only in some versions of ? I believe. I don''t think it works in VC++ either. I could be wrong.
Peon
Advertisement
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 ]
[ Google || Start Here || ACCU || STL || Boost || MSDN || GotW || CUJ || MSVC++ Library Fixes || BarrysWorld || [email=lektrix@barrysworld.com]E-Mail Me[/email] ]

This topic is closed to new replies.

Advertisement