Hello there.... I have a strange problem with loops in C.
Code:
#include <stdio.h>
int main() {
char ch;
while (1) {
printf("Give char: "); scanf("%c",&ch);
if (ch == 'q') break;
}
}
The above loop prints
First line: Give char: <char>
Second Line: Give char: Give char: <char>
Third Line: Give char: Give char: <char>
.
.
.
Well my question is an obvius one. Why the program prints 2 times the "Give char:" in second, third......n line ??
And how i can fix that?
Thanx in Advance !!!