Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

send me the solution.

0 views
Skip to first unread message

wahid

unread,
Jan 10, 2010, 2:06:41 AM1/10/10
to
• 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)

Ian Collins

unread,
Jan 10, 2010, 2:15:30 AM1/10/10
to
wahid wrote:
> � Using getch() command, write a program that

C doesn't have a "getch() command".

Are you incapable of doing anything for your self?

--
Ian Collins

Antoninus Twink

unread,
Jan 10, 2010, 8:15:58 AM1/10/10
to
On 10 Jan 2010 at 7:06, wahid wrote:
> • 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;
}

Lionel Pinkhard

unread,
Jan 19, 2010, 10:55:19 AM1/19/10
to

getch() is something I believe was non-standard and long gone. getchar()
might be what you're looking for.

And, it doesn't take much skill to figure this out for yourself. You already
have most of the solution in your original post.

--
--------------------------------------------------------------
Professional mobile software development
BreezySoft Limited www.breezysoft.com
--------------------------------------------------------------

0 new messages