0

Is there a way to place the prompt programmaticaly in a console application? I'm using Visual Studio 2008.

Thanks

1
  • you mean you want to place the cursor? Commented Apr 4, 2011 at 10:43

3 Answers 3

2

Do you mean moving the blinking thingy? If so I think SetConsoleCursorPosition is what you want. Console Functions reference page http://msdn.microsoft.com/en-us/libr...73(VS.85).aspx

Sign up to request clarification or add additional context in comments.

Comments

2

Assuming you're talking about the output position, you can control it at two levels.

At the highest level, you can use control characters such as carriage return, line feed and backspace. Check out your nearest ASCII table.

At a lower level, you can use the Windows API console functions.

Those functions are in turn divided into two levels, and depending on what you want to control (e.g. response to Ctrl C) you may have to delve down to the very lowest level.

A more portable alternative to is to use some portable "terminal" library such as ncurses.

Cheers & hth.,

Comments

0

Found on the .NET

#include <windows.h> #include <stdio.h> void Locate ( int row, int col ) { if ( row < 0 || row > 24 ) return; if ( col < 0 || col > 79 ) return; COORD c = { (SHORT)col, (SHORT)row }; SetConsoleCursorPosition ( GetStdHandle ( STD_OUTPUT_HANDLE ), c ); } void main ( ) { int row; int col; printf ( "Row (0-24): " ); scanf ( "%d", &row ); printf ( "Col (0-79): " ); scanf ( "%d", &col ); Locate ( row, col ); printf ( "This text is starting at row %d, column %d\n", row, col ); } 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.