title: program that does not terminate
body: <p>I wrote a program that should take an array of numbers and find the array index of the smallest number. However, when I type the numbers with spaces between and then press enter, the program keeps running. What can be the cause? Here is the code:</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  
  //read numbers to an array
  //find minimum
  //print the index of minimum
  
  double findMinimum(int size,double array[]){
  int n;
  int minIndex=0;
  for(n=1;n&lt;size;size++){
      if(array[n]&lt;array[n-1]){
          minIndex=n;
      }
   }
   return minIndex;
  }
  
  int main(){
  setvbuf(stdout,NULL,_IONBF,0);
  
  int size=0;
  double inArray[size];
  
  printf("Enter an array of numbers:");
  
  int k=0;
  char c;
  
  while(c!='\n'){
    c=getchar();
  
    if(c=='\n'){
        break;
    }
  
    scanf("%lf",&amp;inArray[k]);
    k++;
    size++;
  
    };
  
   int minIndex=0;
   minIndex=findMinimum(size,inArray);
   printf("The index of minimum number is %i",minIndex);
  
   return 0;
   }
  </code></pre>
  
  <p>I also took the part of the code that scans numbers to an array. I tried to change the while loop and used "break" statement, but the output gave all numbers in an array except the first one. Here is the code:</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  
  //read numbers to an array
  
  int main(){
  setvbuf(stdout,NULL,_IONBF,0);
  
  int size=0;
  double inArray[size];
  
  printf("Enter an array of numbers ending with question mark:\n");
  
  int k=0;
  char c;
  
  while(1){
    c=getchar();
  
    if(c=='?'){
        break;
    }
  
    scanf("%lf",&amp;inArray[k]);
    k++;
    size++;
  };
  
  int n;
  for(n=0;n&lt;size;n++){
      printf("%f\n",inArray[n]);
  }
  
  return 0;
  }
  </code></pre>
  
  <p>Thanks for help in advance!</p>