send me the solution.

W

wahid

• Using getch() command, write a program that
will echo user key strokes onto the screen, and
if the user presses a letter (A-Z, a-z), the
echoed character will always be a capital
letter. The program terminates when the user
presses the ESC key

• (Hint, ASCII code for ESC is 27, for ‘A’ is 65, and
for ‘a’ is 97. the values are given in decimal
notation)
 
A

Antoninus Twink

• Using getch() command, write a program that will echo user key
strokes onto the screen, and if the user presses a letter (A-Z, a-z),
the echoed character will always be a capital letter. The program
terminates when the user presses the ESC key

#include <stdio.h>
#include <ctype.h>
#include <curses.h>

#define KEY_ESC 27

int main(void)
{
int c, rv = 0;
if(initscr() && cbreak() == OK && noecho() == OK) {
printw("(escape to exit)\n");
refresh();
while((c = getch()) != KEY_ESC) {
printw("%c", toupper(c));
refresh();
}
if(endwin() == ERR)
rv = 1;
} else
rv = 1;
return rv;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,200
Latest member
LaraHunley

Latest Threads

Top