Output to a console is essentially controlled by the console screen buffer's current settings, and each position in the buffer is addressable with a COORD structure. This code uses SetConsoleCursorPosition() to move the current output location to row 11, column 32:
#include <windows.h>
#include <stdio.h>
int main ( int argc, char** argv )
{
HANDLE hConsole = GetStdHandle ( STD_OUTPUT_HANDLE );
if ( INVALID_HANDLE_VALUE != hConsole )
{
COORD pos = {32, 11};
SetConsoleCursorPosition ( hConsole, pos );
printf ( "Hello World!\n" );
}
return 0;
}
Also, code that outputs to cout will respect the buffer settings as well.
[CODE]
Fuente:
The Code Project Visual C++ Forum FAQ
By Michael Dunn
http://www.codeproject.com/cpp/cppforumfaq.asp#cons_gotoxy (http://www.codeproject.com/cpp/cppforumfaq.asp#cons_gotoxy)
HANDLE hHandle=GetStdHandle(STD_OUTPUT_HANDLE);
COORD coord;