while((c=getchar())==’\n’);
NOTE that there is a semicolon at the end.
while((c=getchar())==’\n’);
NOTE that there is a semicolon at the end.
EmbLogic Research & Competency Development Labs
Phone: +91 9818467776, 8527567776, 9650467776
Email: info@emblogic.com
Copyright © EmbLogic Embedded Technologies Pvt. Ltd.
the while statement will be executed only once.
while is executed until condition is true but there is no statement in while because of semicolon so that it only takes input and compare it with ‘\n’ if condition is true loop is continue otherwise it break.
the actual problem was found with switch. if i use choise as an integer variable but press a character instead of integer at the time of making choise… it will go to default but also will move to infinite loop.
to solve that I had to use the code given above… but I am still not able to understand the significance of using this line…@sheetal if I entered hello\n(Enter) then, how will it be treated..??
switch goes infinite because there is some characters in stdin stream that is taken by scanf() this problem can be solved if you clear the input stream.