如果我使用 turbo cpp 编译器,如何禁用输出 window 中闪烁的光标?
How to disable the blinking cursor in the output window if i m using turbo cpp compiler?
我使用 turbo 中的一些标准函数制作了一个简单的程序来显示当前日期和时间 cpp.I 想知道如何从输出 window 中关闭闪烁的光标。我当前的代码如下:
#include<conio.h>
#include<stdio.h>
#include<time.h>
void main()
{
time_t t;
printf("Day and time \n\n");
while(1)
{
time(&t);
clrscr();
printf("Day and time is \n%s",ctime(&t));
delay(1000);
if(kbhit())
break;//breaks the infinite loop if any key is hit
}
getch();
}
您的问题的解决方案是 _setcursortype() 函数。
问题。 什么是 _setcursortype() 函数,它为您提供了哪些功能?
Ans- 首先,setcursortype() 函数不是 ANSI/ISO C 标准函数。
其次,它在 conio.h 中定义,并由旧编译器(如 turbo c)提供,显然不可移植。
我用一个简单的 C 代码解释了 _setcursortype() 提供的所有功能。
这段代码 运行 在我的 turboc 上,所以我希望它肯定会 运行 你自己。 :)
#include<stdio.h>
#iclude<conio.h>
int main()
{
printf("Normal Cursor: "); getch(); /* Display the normal cursor */
_setcursortype(_NOCURSOR);
printf("No Cursor : "); getch(); /* Turn off the cursor */
_setcursortype(_SOLIDCURSOR);
printf("Solid Cursor : "); getch(); /* Switch to a solid cursor */
_setcursortype(_NORMALCURSOR);
printf("Normal Cursor: "); getch(); /* Switch back to the normal cursor */
return 0;
getch();
}
它还可以帮助您了解如何关闭或禁用 turbo c 控制台 window 上闪烁的光标。:)
我使用 turbo 中的一些标准函数制作了一个简单的程序来显示当前日期和时间 cpp.I 想知道如何从输出 window 中关闭闪烁的光标。我当前的代码如下:
#include<conio.h>
#include<stdio.h>
#include<time.h>
void main()
{
time_t t;
printf("Day and time \n\n");
while(1)
{
time(&t);
clrscr();
printf("Day and time is \n%s",ctime(&t));
delay(1000);
if(kbhit())
break;//breaks the infinite loop if any key is hit
}
getch();
}
您的问题的解决方案是 _setcursortype() 函数。
问题。 什么是 _setcursortype() 函数,它为您提供了哪些功能?
Ans- 首先,setcursortype() 函数不是 ANSI/ISO C 标准函数。 其次,它在 conio.h 中定义,并由旧编译器(如 turbo c)提供,显然不可移植。
我用一个简单的 C 代码解释了 _setcursortype() 提供的所有功能。 这段代码 运行 在我的 turboc 上,所以我希望它肯定会 运行 你自己。 :)
#include<stdio.h>
#iclude<conio.h>
int main()
{
printf("Normal Cursor: "); getch(); /* Display the normal cursor */
_setcursortype(_NOCURSOR);
printf("No Cursor : "); getch(); /* Turn off the cursor */
_setcursortype(_SOLIDCURSOR);
printf("Solid Cursor : "); getch(); /* Switch to a solid cursor */
_setcursortype(_NORMALCURSOR);
printf("Normal Cursor: "); getch(); /* Switch back to the normal cursor */
return 0;
getch();
}
它还可以帮助您了解如何关闭或禁用 turbo c 控制台 window 上闪烁的光标。:)