lcs81
Member level 3
1 main (){
2 int no, i, j, k;
3 printf("Enter three values: ");
4 no=scanf("%d %d %d",&i, &j, &k);
5 while (no<3){
7 while (getchar()!= '\n'){}
8 printf("you only type %d value correctly\n", no);
9 printf("Try again:");
10 num_input=scanf("%d %d %d", &i, &j, &k);
11 } }
When line 7 doesnt exits, the program will loop infinitely.
I just dont really undestant why just cannot ignore line 7.
Can any one explain what line 7 doing?
Is line 4 common in used?What is means?
Thanks
2 int no, i, j, k;
3 printf("Enter three values: ");
4 no=scanf("%d %d %d",&i, &j, &k);
5 while (no<3){
7 while (getchar()!= '\n'){}
8 printf("you only type %d value correctly\n", no);
9 printf("Try again:");
10 num_input=scanf("%d %d %d", &i, &j, &k);
11 } }
When line 7 doesnt exits, the program will loop infinitely.
I just dont really undestant why just cannot ignore line 7.
Can any one explain what line 7 doing?
Is line 4 common in used?What is means?
Thanks