此代码是将光标跳到指定位置。
gotoxy(x,y) x代表行,y代表列,下标是从0开始的
#include<iostream>
#include<windows.h>
#include<stdio.h>
#include<string.h>
using namespace std;
void gotoxy(int x,int y)//位置函数
{
COORD pos;
pos.X=y;
pos.Y=x;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);
}
int main()
{
cout<<"sssssssss"<<endl;
gotoxy(0,1);
getchar();
return 0;
}
在控制台程序中获取鼠标事件。
下面给出一个小程序