this is the part of a code. I tried to run the programs. Whole program is working fine the only problem is the line with comment is not accepting any input. Is it possible that the break statement is breaking the whole loop?Code:do { printf("\n1.PUSH"); printf("\n2.POP"); printf("\n3.TRAVERSE"); printf("\nEnter your choice"); scanf("%d",&choice); switch(choice) { case 1: push(); break; case 2: pop(); break; case 3: traverse(); break; default : printf("\nwrong choice"); } printf("\n do you wish to continue(Y/N)"); scanf("%c",&ch); // This line is not working } while(ch =='Y'|| ch =='y');
Edit: Just now i tried by changing the declaration of ch to 'char ch[2]' and then commented line to 'scanf("%s",ch);' and condition of whole to 'ch[0]== 'Y')' now everything is working fine. What was wrong with '%c'?
Bookmarks