1 #include"stdio.h" 2 #include"windows.h" 3 //#include"stdbool.h" 4 /* 5 void cursor(int cursor_size,int cursor_vi) 6 cursor_size 光标大小,范围为从1到100,1最小,100最大; 7 cursor_vi 光标可见性,为0或false为不可见,为1或ture为可见; 8 */ 9 //note110 //note2 11 void cursor(int cursor_size,BOOL cursor_vi)12 {13 if((cursor_size<0)||(cursor_size>100)||((cursor_vi!=0)&&(cursor_vi!=1)))14 {15 printf("\nWarnning from cursor(): 1<=cursor_size<=100 cursor_vi=0 or cursor_vi=1\n");16 cursor_size=1;17 cursor_vi=1;18 }19 CONSOLE_CURSOR_INFO cursor_info = {cursor_size, cursor_vi}; 20 SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);21 }22 void main()23 {24 system("pause");25 cursor(1,0);26 printf("The Cursor is hidded.\n");27 system("pause");28 cursor(1,1);29 printf("The Cursor is visible.\n");30 system("pause");31 }32 /*33 函数和结构体都在windows.h中有定义34 35 CONSOLE_CURSOR_INFO结构体定义如下:36 37 typedef struct38 { DWORD dwSize;//范围为1到10039 BOOL bVisible; //0或false 光标不可见 1或true 光标可见40 }CONSOLE_CURSOR_INFO, *PCONSOLE_CURSOR_INFO;41 */