answersLogoWhite

0

getch(); is used for unbuffered input. e.x:

int main()

{

char num=0;

printf("Press a keyboard button: ");

num = getch(); //This brings in 1 character that the user pressed on the keyboard

printf("\nYou pressed: %c", num); //This prints the character you pressed

getchar(); // I am using getchar(); to stop the program from ending after pressing buttons

return 0;

}

My input will be within the ().

output:

Press a keyboard button: (v)

You pressed: v

EOP //End of program

I hope this has helped you!

User Avatar

Wiki User

12y ago

What else can I help you with?

Related Questions

Return value of getch?

char


What is the return value of getch function?

It returns an int, representing a character. (Basically, chars are ints.) However, if EOF (End-Of-File) has been read, it will return EOF (-1) and set the eof error flag accordingly.


Give an code for getch?

#include <conio.h> #include <stdio.h> int mygetch (void) { int x; x= getch (); if (x==0) x= 1000+getch(); return x; } int main (void) { int key; key = mygetch (); if (key==1059) printf ("F1\n"); else printf ("%d\n", key); return 0; }


Find the absolute value write a program of a no entered through the keyboard?

#include<stdio.h> #include<conio.h> int main () { int num; printf("enter the number"); scanf("%d",&num); if(num<0) num=(-1)*num; printf("absolute value=%d",num); getch(); return 0; }


Difference in using a method that return value and method that does not return value in object orinted programming?

A method that return a value should have a return statement. The method signature should indicate the type of return value. While in the case of a method that does not return a value should not have a return statement and in the signature, the return type is void. When using a method that doesn't return a value, a programmer can not get a value from that function, but instead, it can only change variable values and run other methods.


Can we perform bitwise circular shift in c?

Yes: unsigned char CircLeft (unsigned char value) { if (value&0x80) return (value<<1) + 1; else return (value<<1); } unsigned char CircRight (unsigned char value) { if (value&0x01) return (value>>1) + 0x80; else return (value>>1); }


What is wrong with not writing a return statement in value-returning method in java?

It is a syntax error, because a value returning method must return a value, and not writing a return statement with a value is tantamount to returning without a value.


Purpose of getch?

The purpose of getch() is to input a single character from the input stream.


What is the calculation for the daily return of an investment?

The calculation for the daily return of an investment is: (Ending Value - Beginning Value) / Beginning Value.


How do you return a value in a PHP function?

Below is a simple example of how you could return a value in a PHP function. <?php function returnme($value) { return $value; } echo returnme('hello'); // outputs: hello ?>


Can you use printf as a return value?

No, it is a function. But printf does return a value: the number of characters it has written.


What statement returns a value from a function?

return