[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
CCursor
The coordinates is set like this:
In this code the coordinates is set to (40,12.5).
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
CCursor
(C) Cursor
Setting the cursor position
Here is a small program that can change the position of the cursor, to anywhere on the screen.The coordinates is set like this:
cursor_coord.X=(40-(strlen(buffer)/2));
cursor_coord.Y=12.5;
In this code the coordinates is set to (40,12.5).
int main() { HANDLE console_handle; COORD cursor_coord; char *buffer = "Cursor Position: (40,12.5)"; DWORD actual=0; cursor_coord.X=(40-(strlen(buffer)/2)); cursor_coord.Y=12.5; console_handle= GetStdHandle( STD_OUTPUT_HANDLE); if (SetConsoleCursorPosition(console_handle,cursor_coord)) WriteConsole(console_handle,buffer,strlen(buffer),&actual,NULL); }
- include <windows.h>
Code links
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
