Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   send me the solution. (http://www.velocityreviews.com/forums/t711317-send-me-the-solution.html)

wahid 01-10-2010 07:06 AM

send me the solution.
 
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 01-10-2010 07:15 AM

Re: send me the solution.
 
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 01-10-2010 01:15 PM

Re: send me the solution.
 
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;
}



All times are GMT. The time now is 09:31 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.