0

I just don't understand where is the wrong? when I taking the input value without Y or y then output shows two times then I can again take input but it should be one time. So can anyone help me?

    I AM SORRY COCO 
    Do you want to stop me?
    I AM SORRY COCO
    Do you want to stop me?
char stop;
while(1){
    printf("I AM SORRY COCO\n");
    printf("Do you want to stop me?\n");
    scanf("%c",&stop);
    if(stop=='Y'||stop=='y'){
        break;
    }
  • 1
    You type a "N" and hit the return key, don't you? Two keys pressed, two times through the loop. – RubberBee Jul 23 '20 at 06:10
  • So how can i solve this? – Emila Rahman Jul 23 '20 at 11:35
  • Does this answer your question https://stackoverflow.com/a/34049496/12938627 ? – RubberBee Jul 23 '20 at 11:40
  • Or what was given as duplicate in the close reason? – RubberBee Jul 23 '20 at 11:40
  • no it's not that but why it's duplicate?i don't know – Emila Rahman Jul 23 '20 at 14:51
  • Can you see the banner at the top of the page, telling you that this question was closed as a duplicate and why, i.e. which other Q/A is considered to ask and answer the same? – RubberBee Jul 24 '20 at 07:39
  • If the two links really do not help then debug your code by inserting a `printf("(%c)\n", stop);` right before your `if`. That should put you on the path to find your problem yourself. And frankly, when you did I bet you will realise that it is what is described in the links.... – RubberBee Jul 24 '20 at 07:43

0 Answers0