int arr2d_sumElements( int arr2d[ ] [ NCOLS] , int nrows ) {
int sum = 0 ;
// sanity check
if ( ! arr2d || nrows < 1 )
return INT_MIN;
// actual calc
int * walk = ( int * ) arr2d;
// address of arr2d's 1st int element
int * stop = ( ( int * ) arr2d + nrows * NCOLS) ;
// address of arr2d's last int element
while ( walk < stop )
sum += * walk++;
return sum;
}
aW50IGFycjJkX3N1bUVsZW1lbnRzKCBpbnQgYXJyMmRbXVtOQ09MU10sIGludCBucm93cyApeyAgICAgICAgCiAgICBpbnQgc3VtID0gMDsgICAgICAgIAogICAgLy8gc2FuaXR5IGNoZWNrICAgICAgICAKICAgIGlmICggIWFycjJkIHx8IG5yb3dzIDwgMSApICAgICAgICAgICAgICAgCiAgICByZXR1cm4gSU5UX01JTjsgICAgICAgIAogICAgLy8gYWN0dWFsIGNhbGMgICAgICAgIAogICAgaW50ICp3YWxrID0gKGludCAqKWFycjJkOyAgICAgICAgICAgICAgICAgICAgICAgCiAgICAvLyBhZGRyZXNzIG9mIGFycjJkJ3MgMXN0IGludCBlbGVtZW50ICAgICAgICAKICAgIGludCAqc3RvcCA9ICgoaW50ICopYXJyMmQgKyBucm93cyAqIE5DT0xTKTsgICAgIAogICAgLy8gYWRkcmVzcyBvZiBhcnIyZCdzIGxhc3QgaW50IGVsZW1lbnQgICAgICAgCiAgICB3aGlsZSAoIHdhbGsgPCBzdG9wICkgICAgICAgICAgICAgICAgCiAgICBzdW0gKz0gKndhbGsrKzsgICAgICAgIAogICAgcmV0dXJuIHN1bTsKICAgIAp9
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