title: My C program is exiting with a non-zero status and I don't know why. Currently running the code in repl.it
body: <p>Hi I'm currently running a code in c programming, and it keeps exiting with a non-zero status.</p>
  
  <p>The code is being used for a sudoku game and what I'm essentially trying to do is generate a random 9x9 2D array. After randomly generating it, I have a function checking if the grid is a valid grid. I don't know why I'm getting a non-zero status.There might be something wrong with the method of how I'm randomly generating the numeber but I'm not sure. Help is appreciated thank you.</p>
  
  <pre><code>#include "stdio.h"
  #include &lt;time.h&gt;
  #include &lt;stdlib.h&gt;
  
  
  int check(int list[][9]){
      // Disable stdout buffering
      setvbuf(stdout, NULL, _IONBF, 0);
  
      int i, j, x, y, ans = 0, sum = 0, sum2 = 0, sum3 = 0;
  
      for(i=0;i&lt;9;i++){               //This nested for loop checks if columns and rows are correct
        sum = 0;
        sum2 = 0;
        for(j=0;j&lt;9;j++){
          sum += list[i][j];
          sum2 += list[j][i];
          if((j == 8) &amp;&amp; ((sum != 45) || (sum2 != 45)))
           ans = 1;
        }
      }
  
      for(x=0;x&lt;3;x++){         //This nested for loop checks if boxes are right
        for(y=0;y&lt;3;y++){
          sum3=0;
          for(i=0;i&lt;3;i++){
            for(j=0;j&lt;3;j++){
              sum3+= list[i+(3*y)][j+(3*x)];
              if((i==2 &amp;&amp; j==2) &amp;&amp; (sum3 != 45))
                ans = 1;
            }
          }
        }
      }
  
      return ans;
  }
  
  
  
  
  int main(void){
    // Disable stdout buffering
    setvbuf(stdout, NULL, _IONBF, 0);
  
    int list[9][9] = {0,0,0,0,0,0,0,0,0,
                      0,0,0,0,0,0,0,0,0,
                      0,0,0,0,0,0,0,0,0,
                      0,0,0,0,0,0,0,0,0,
                      0,0,0,0,0,0,0,0,0,
                      0,0,0,0,0,0,0,0,0,
                      0,0,0,0,0,0,0,0,0,
                      0,0,0,0,0,0,0,0,0,
                      0,0,0,0,0,0,0,0,0};
  
  
    int i, j, r;
  
    for(;;i++){
  
      for(i=0; i&lt;9; i++){
         for(j=0; j&lt;9; j++){
          srand(time(NULL));
          r = rand() % ((9 + 1 - 1) + 1);
          list[i][j] = r;
        }
      }
  
      if(check(list[i][j]) == 0)
        break;
    }
  
    printf("done");
  
    return 0;
  }
  </code></pre>