title: Unreasonable error calling function in C - Program to sort an array
body: <p>I wrote a program that receive from user a series of numbers (&lt;=20) while the last '0' means end of series (not included in series storing).
  2 arrays (x,y) size 20 (0-19 + 1 for the '0') must be zeros, and m means number of organs in Y array.</p>
  
  <p>The user must enter numbers ascending (it is ok 4ex. 1,2,2,3,7,8,...,0) and end with a '0' of course, if not, appropriate error message will appear, and program will shut off.</p>
  
  <p>We can be sure the user will keep the &lt;=20 numbers of input.</p>
  
  <p>Y array will be (if everything went ok with X array) a sorted array of X but without duplicates.
  'm' will be number of organs in Y exclude '0' of course.</p>
  
  <p>Function SIFT must only organize the Y array for being printed from main().</p>
  
  <p>Example:</p>
  
  <p>If user will store in X: 1,1,2,3,5,5,5,6</p>
  
  <p>On screen will be: m = 5  Y = 1,2,3,5,6</p>
  
  <p><strong>My tryout:</strong></p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  void SIFT(int x_arr[ ], int y_arr[]);
  
  int main ()
  {
      int x[20] = {0} , y[20] = {0};
      int m=0,temp=0,curr=0,i=0,j=0;
  
      printf("Please enter your numbers now:\n\n");
  
      /*enter numbers one by one. if x[i+1] value &lt; x[i] value, err msg.
        when user want to end the series he must enter '0' which means end of string (it wont       included in x[]) */
      while ( ( temp = getchar() ) != '0' )
      {
          if (temp &gt;= curr)
          {
              x[i] = temp;
              curr = temp;
              i++;
          }
          else
          {
              printf("The numbers are not at the right order !\n\nProgram will now terminate...\n\n");
          }
      }
  
      SIFT(x,y);
  
      for (i=0 ; y[i]=='0' ; i++) /*strlen(y) without ('0')'s includes*/
          m++;
  
      /*Prints  m , y's organs*/
      printf("\n\nm = %d",m);
      printf("Y = ");
      while (y[j]!='0')
      {
          printf ("%d ,",y[j]);
          j++;
      }
  
  void SIFT(int x_arr[ ], int y_arr[])
  {
      int i=0,j=0;
  
      while (x_arr[i] != '0')
      {
          if (x_arr[i] == x_arr[i+1]) /*if current val. equals next val. -&gt; jump dbl at x_arr*/
          {
              y_arr[j] = x_arr[i];
              i+=2;
              j++;
          }
          else
          {
              y_arr[j]=x_arr[i];
              i++;
              j++;
          }
      }    
  
  }
  
  return 0;
  }
  </code></pre>
  
  <p><strong>The error I'm getting from the gcc is:</strong></p>
  
  <pre><code>gcc -g -ansi -pedantic -Wall 2.c -o 2   
  2.c: In function ‘main’:
  2.c:43: warning: ISO C forbids nested functions
  2.c:43: warning: ISO C90 forbids mixed declarations and code
  /tmp/ccyZNfkF.o: In function `main':
  /home/student/Desktop/2/2.c:29: undefined reference to `SIFT'
  collect2: ld returned 1 exit status
  make: *** [2] Error 1
  </code></pre>
  
  <p><strong>And another question:</strong></p>
  
  <p>I would like to convert this code to the MIPS Assembly code, is there a short and fast way to do so ?</p>
  
  <p>Thanks all you guys !!</p>