Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Press enter to continue after yes/no in C
- while (getchar() != 'n');
- int main (int argc, const char * argv[]) {
- printf("Would you like to continue? Please press y or n.n");
- if(getchar() == 'y'){
- printf("You pressed yes! Continuing...");
- }
- else{
- printf("Pressed no instead of yes.");
- }
- //flush commands go here
- printf("nPress ENTER to continue...");
- if(getchar()=='n'){
- printf("nGood work!");
- }else{
- printf("Didn't hit ENTER...");
- return 0;
- }
- 1. Single character input
- 2. 3 character String
- #include<stdio.h>
- int main()
- {
- char ch[3];
- char c;
- int i=0;
- while(((c=getchar())!='n')){
- ch[i]=c;
- i++;
- }
- ch[i]='