To use ncurses in your program, you first need to install ncurses. Once installed, write the below code:
#include <ncurses.h>
#include <stdio.h>
#include <stdlib.h>
int main() {
int ch;
initscr();
raw();
keypad(stdscr, TRUE);
noecho();
printw("Type any character to see it in bold\n");
ch = getch();
if (ch == KEY_F(1))
printw("F1 Key pressed");
else {
printw("The pressed key is ");
attron(A_BOLD);
printw("%c", ch);
attroff(A_BOLD);
}
refresh();
getch();
endwin();
return EXIT_SUCCESS;
}
#include <ncurses.h>
#include <stdio.h>
#include <stdlib.h>
int main() {
int ch;
initscr();
raw();
keypad(stdscr, TRUE);
noecho();
printw("Type any character to see it in bold\n");
ch = getch();
if (ch == KEY_F(1))
printw("F1 Key pressed");
else {
printw("The pressed key is ");
attron(A_BOLD);
printw("%c", ch);
attroff(A_BOLD);
}
refresh();
getch();
endwin();
return EXIT_SUCCESS;
}
To compile it, use the ncurses library using
$ gcc file.c -lncurses
$ gcc file.c -lncurses
Once compiled, it will generate a executable named a.out
Type any character to see it in bold
The pressed key is A
If you need any help installing ncurses, write in comment section.