fork download
  1. int arr2d_sumElements( int arr2d[][NCOLS], int nrows ){
  2. int sum = 0;
  3. // sanity check
  4. if ( !arr2d || nrows < 1 )
  5. return INT_MIN;
  6. // actual calc
  7. int *walk = (int *)arr2d;
  8. // address of arr2d's 1st int element
  9. int *stop = ((int *)arr2d + nrows * NCOLS);
  10. // address of arr2d's last int element
  11. while ( walk < stop )
  12. sum += *walk++;
  13. return sum;
  14.  
  15. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:1: error: ‘NCOLS’ undeclared here (not in a function)
prog.c: In function ‘arr2d_sumElements’:
prog.c:5: error: ‘INT_MIN’ undeclared (first use in this function)
prog.c:5: error: (Each undeclared identifier is reported only once
prog.c:5: error: for each function it appears in.)
prog.c:9: error: ‘NCOLS’ undeclared (first use in this function)
stdout
Standard output is empty