I teach C on the textbook. I'm sitting on linux mint. Gcc compiler

The question itself:
Why when I start to enter data into the program (suppose that I enter: 45.2, 48.3, Speed ​​= 23) I need to press enter then enter another character and only then the program will continue. Why enter another character? Why the first time you press the enter key, the program does not immediately display the values?

#include <stdio.h> void main() { float lantitude; float longitude; char speed[80]; puts ("Data:\n"); while(scanf("%f, %f, %79[^\n]",&lantitude,&longitude,speed)==3); { printf("lantitude: %f, longitude: %f,info: %s", lantitude,longitude,speed); puts(";\n"); } } 
  • one
    It is not clear how you enter the data. Show the input line. - Vlad from Moscow

1 answer 1

 while(scanf("%f, %f, %79[^\n]",&lantitude,&longitude,speed)==3); 

Those. while you enter the correct string (read 3 values), this must be done again and again (see the semicolon).

When something is finally entered incorrectly, you can proceed to the conclusion of the entered ...

So?