title: How to scanf multiple inputs separeted by space in C?
body: <p>I am new in proggraming and i can't solve a problem. So i have to scanf and check if it is an integer (int n), and than read n floats (with checking if they are floats). Problem is that machine tests add multiple floats separeted by space in input and i don't know how to get these numbers.</p>
  
  <p>I wrote something like this:</p>
  
  <pre><code>  int n;
    if(!scanf("%d", &amp;n)){
      printf("Invalid input");
      return 1;
    }
    float *tab = malloc(n*sizeof(float));
    printf("Enter variables: ");
    for(int i=0; i&lt;n; i++){
      if(scanf("%f", (tab+i))!=1){
        printf("Incorrect input data");
        return 2;
      }
    }
  </code></pre>
  
  <p>I don't know if it is good and what to do if you input less or more numbers in input.
  Guys, please explain me what is wrong here and how to solve it.</p>
  
  <p>Thanks for your time.</p>