What is the purpose of the getch() function in C?
The getch()
function (getchar means get char) is used to read a character or a key from the keyboard. This function is blocking until the user presses a key. The character is not displayed on the screen.
Here is an example of use:
#include <stdio.h>
#include <conio.h> // Pour la fonction getch()
int main()
{
char ch;
printf("Appuyez sur une touche pour continuer.\n");
// Attend un appui sur une touche
ch = getch();
printf ("Vous avez appuyé sur la touche %c.\n", ch);
return 0;
}
The getch()
function (getchar means get char) is used to read a character or a key from the keyboard. This function is blocking until the user presses a key. The character is not displayed on the screen.
Here is an example of use:
#include <stdio.h>
#include <conio.h> // Pour la fonction getch()
int main()
{
char ch;
printf("Appuyez sur une touche pour continuer.\n");
// Attend un appui sur une touche
ch = getch();
printf ("Vous avez appuyé sur la touche %c.\n", ch);
return 0;
}
# | ID | Query | URL | Count |
---|