Другие языки программирования и технологии
Как на языке C возвратиться вверх на 1 строку?
На клавиатуре нажать стрелку вверх )) (какой вопрос такой и ответ).
SetConsoleCursorPosition Function
Sets the cursor position in the specified console screen buffer.
Syntax
BOOL WINAPI SetConsoleCursorPosition(
__in HANDLE hConsoleOutput,
__in COORD dwCursorPosition
);
Parameters
hConsoleOutput [in]
A handle to the console screen buffer. The handle must have the GENERIC_READ access right. For more information, see Console Buffer Security and Access Rights.
dwCursorPosition [in]
A COORD structure that specifies the new cursor position, in characters. The coordinates are the column and row of a screen buffer character cell. The coordinates must be within the boundaries of the console screen buffer.
Return Value
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
COORD Structure
Defines the coordinates of a character cell in a console screen buffer. The origin of the coordinate system (0,0) is at the top, left cell of the buffer.
Syntax
typedef struct _COORD {
SHORT X;
SHORT Y;
}COORD, *PCOORD;
Members
X
The horizontal coordinate or column value. The units depend on the function call.
Y
The vertical coordinate or row value. The units depend on the function call.
GetConsoleScreenBufferInfo Function
Retrieves information about the specified console screen buffer.
Syntax
BOOL WINAPI GetConsoleScreenBufferInfo(
__in HANDLE hConsoleOutput,
__out PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo
);
Parameters
hConsoleOutput [in]
A handle to the console screen buffer. The handle must have the GENERIC_READ access right. For more information, see Console Buffer Security and Access Rights.
lpConsoleScreenBufferInfo [out]
A pointer to a CONSOLE_SCREEN_BUFFER_INFO structure that receives the console screen buffer information.
CONSOLE_SCREEN_BUFFER_INFO Structure
Contains information about a console screen buffer.
Syntax
typedef struct _CONSOLE_SCREEN_BUFFER_INFO {
COORD dwSize;
COORD dwCursorPosition;
WORD wAttributes;
SMALL_RECT srWindow;
COORD dwMaximumWindowSize;
}CONSOLE_SCREEN_BUFFER_INFO;
Members
dwSize
A COORD structure that contains the size of the console screen buffer, in character columns and rows.
dwCursorPosition
A COORD structure that contains the column and row coordinates of the cursor in the console screen buffer.
wAttributes
The attributes of the characters written to a screen buffer by the WriteFile and WriteConsole functions, or echoed to a screen buffer by the ReadFile and ReadConsole functions. For more information, see Character Attributes.
srWindow
A SMALL_RECT structure that contains the console screen buffer coordinates of the upper-left and lower-right corners of the display window.
dwMaximumWindowSize
A COORD structure that contains the maximum size of the console window, in character columns and rows, given the current screen buffer size and font and the screen size.
microsoft Windows SDK
Sets the cursor position in the specified console screen buffer.
Syntax
BOOL WINAPI SetConsoleCursorPosition(
__in HANDLE hConsoleOutput,
__in COORD dwCursorPosition
);
Parameters
hConsoleOutput [in]
A handle to the console screen buffer. The handle must have the GENERIC_READ access right. For more information, see Console Buffer Security and Access Rights.
dwCursorPosition [in]
A COORD structure that specifies the new cursor position, in characters. The coordinates are the column and row of a screen buffer character cell. The coordinates must be within the boundaries of the console screen buffer.
Return Value
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
COORD Structure
Defines the coordinates of a character cell in a console screen buffer. The origin of the coordinate system (0,0) is at the top, left cell of the buffer.
Syntax
typedef struct _COORD {
SHORT X;
SHORT Y;
}COORD, *PCOORD;
Members
X
The horizontal coordinate or column value. The units depend on the function call.
Y
The vertical coordinate or row value. The units depend on the function call.
GetConsoleScreenBufferInfo Function
Retrieves information about the specified console screen buffer.
Syntax
BOOL WINAPI GetConsoleScreenBufferInfo(
__in HANDLE hConsoleOutput,
__out PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo
);
Parameters
hConsoleOutput [in]
A handle to the console screen buffer. The handle must have the GENERIC_READ access right. For more information, see Console Buffer Security and Access Rights.
lpConsoleScreenBufferInfo [out]
A pointer to a CONSOLE_SCREEN_BUFFER_INFO structure that receives the console screen buffer information.
CONSOLE_SCREEN_BUFFER_INFO Structure
Contains information about a console screen buffer.
Syntax
typedef struct _CONSOLE_SCREEN_BUFFER_INFO {
COORD dwSize;
COORD dwCursorPosition;
WORD wAttributes;
SMALL_RECT srWindow;
COORD dwMaximumWindowSize;
}CONSOLE_SCREEN_BUFFER_INFO;
Members
dwSize
A COORD structure that contains the size of the console screen buffer, in character columns and rows.
dwCursorPosition
A COORD structure that contains the column and row coordinates of the cursor in the console screen buffer.
wAttributes
The attributes of the characters written to a screen buffer by the WriteFile and WriteConsole functions, or echoed to a screen buffer by the ReadFile and ReadConsole functions. For more information, see Character Attributes.
srWindow
A SMALL_RECT structure that contains the console screen buffer coordinates of the upper-left and lower-right corners of the display window.
dwMaximumWindowSize
A COORD structure that contains the maximum size of the console window, in character columns and rows, given the current screen buffer size and font and the screen size.
microsoft Windows SDK
тебе нужно вставить в свой код вот такую функцию
а потом указывать координаты, в какое место ты хочешь вернуться например
gotoxy(10,11); ты вернешься на 11 строку и на 10 пробелов, только если ты с консолью работаешь
void gotoxy(int xpos, int ypos)
{
COORD scrn;
HANDLE hOuput = GetStdHandle(STD_OUTPUT_HANDLE);
scrn.X = xpos; scrn.Y = ypos;
SetConsoleCursorPosition(hOuput,scrn);
}
а потом указывать координаты, в какое место ты хочешь вернуться например
gotoxy(10,11); ты вернешься на 11 строку и на 10 пробелов, только если ты с консолью работаешь
void gotoxy(int xpos, int ypos)
{
COORD scrn;
HANDLE hOuput = GetStdHandle(STD_OUTPUT_HANDLE);
scrn.X = xpos; scrn.Y = ypos;
SetConsoleCursorPosition(hOuput,scrn);
}
Похожие вопросы
- где можно выучить язык c++ для читов cs 1.6? (имею виду не весь с++ а ток то что нужно для читов)
- Помогите!! C ++ Вводится число от 1...999. Вывести данное число на естественном языке. Например, 52 – пятьдесят два.
- Вопрос для тех кто знает точный ответ, язык C про функции все подробности вопроса внутри...
- Как можно написать программу на языке C, которая будет выводить числа от 1 до 1000 без if, switch, do, while, for, goto?
- Вопрос актуальности языка C++, расхождение источников. Мне нужна достоверная инфа на это счет.
- Равны ли по мощности, гибкости языки C# и C++. Равны ли по мощности, гибкости языки C# и C++ или какой то из них мощнее?
- Я так понимаю, что бы создать графический интерфейс, например игру, недостаточно языка c++ ?
- Вопрос по изучению языка C++?
- Программирование! По языку C#!
- C++. Поменять местами слова в строке