Can anyone please help me, how do I take in the enter key as an input in C? or like some program like this ---->> " Please enter a key to go to next line" <<------ How to add this type of option in C.
I am new in programing. Anyone, please help me.
CodePudding user response:
You can use the getc function in stdio.h to wait until a key is pressed. This C code will wait for the enter key to be pressed then output "Continued!":
#include <stdio.h>
int main(){
printf("Press any key to continue");
getc(stdin);
printf("Continued!");
return 0;
}
CodePudding user response:
If I understand your question, you can write:
printf("Press ENTER key to Continue\n");
getchar();
Or
printf("Press Any Key to Continue\n");
getch();
