How to change cursor style using C
In this article, we will discuss how to change the cursor style on the screen in C.
Approach: The idea is to use the setcursortype() function to change the cursor style on the output screen. This function takes cursor-type as an argument and is declared under the conio.h header file.
Header File:
#include <conio.h>
Below are the list of valid cursor-type:
- _NOCURSOR: Turns off the cursor.
- _NORMALCURSOR: Normal underscore cursor.
- _SOLIDCURSOR: Solid block cursor.
Syntax:
void _setcursortype(int cursor-type)
Program 1:
Below is the program for changing the cursor type to _NOCURSOR:
C
#include <conio.h>
#include <stdio.h>
int main()
{
_setcursortype(_NOCURSOR);
cprintf( "No Cursor :" );
return 0;
}
|
Output:
Below is the output of the above program:
Program 2:
Below is the program for changing the cursor type to _SOLIDCURSOR:
C
#include <conio.h>
#include <stdio.h>
int main()
{
_setcursortype(_SOLIDCURSOR);
cprintf( "Solid Cursor :" );
return 0;
}
|
Output:
Below is the output of the above program:
Program 3:
Below is the program for changing the cursor type to _NORMALCURSOR:
C
#include <conio.h>
#include <stdio.h>
int main()
{
_setcursortype(_NORMALCURSOR);
cprintf( "Normal Cursor :" );
return 0;
}
|
Output:
Below is the output of the above program:
Last Updated :
18 Aug, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...