"I am not able to stop my program until I input two numbers when I use scanf("%d\n",&i);
"
Although this format makes scanf
read the number and store it into i
, this "reading" continues and it lasts till non-whitespace character followed by \n
is found. This is the reason why input 1 2
makes this scanf
stop.
You should not specify newline in the input format in this case.
Use scanf("%d",&i);
instead.