Public Group

Archived

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

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

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

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 on other sites
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 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 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 on other sites
would gotoxy(1,1) work?

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 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 ]

• 9
• 9
• 13
• 41
• 15