I used several similar messages to change the code, however, warnings are still generated.
$ g++ ncfile.c -o ncfile -g -lnetcdf ncfile.c: In function 'int main(int, char**)': ncfile.c:363: warning: format '%d' expects type 'int', but argument 4 has type 'size_t' ncfile.c:363: warning: format '%d' expects type 'int', but argument 4 has type 'size_t' ncfile.c:364: warning: format '%d' expects type 'int', but argument 4 has type 'size_t' ncfile.c:364: warning: format '%d' expects type 'int', but argument 4 has type 'size_t'
In this block around lines 363 and 364:
for(i = 0; i < ndimsp; i++) { char * temp_name; size_t temp_len; temp_name = (char *)malloc(sizeof(char) * 20); nc_inq_dim(cid, dimids[i], temp_name, &temp_len); dimlens[i] = temp_len; if(dimids[i] == unlimdimidp) printf("\t\t%d %s \tlength: %d (UNLIMITED)\n", i, temp_name, temp_len); else printf("\t\t%d %s \tlength: %d\n", i, temp_name, temp_len); total_records *= temp_len; free(temp_name); }
How can I get rid of warnings. Is it bad for the results?
Thanks,
Michael
source share