Hello people!
I am learning C programming for sometime.Some days before i got this problem.Problem is that i cannot understand this While Loop!
Statement is..
----while(scanf("%i",&j) != 1){
while(( ch = getchar() != '\n')
;
printf("Enter your integer:");
}
---------------
Some other loops similar to Above are also used in that book.The problem is I do not know why he first tested the value of variable "j" against "1" in first scanf().As scanf takes the input from keyboard and then saves it in "j" but why it is tested against "1" .
The author explains nothing ,he says that there is a problem in buffering characters in scanf() so to avoid this we use this loop?
------Also explain that why he put ""Do Nothing loop"" in the statement .I try to understand this one according to my information it is taking input by getchar() assigning this value to "ch" and testing it against "\n" which is for Enter key but why we put ; on next line....
I would be thankful if you would explain this????