4
코드를 수정하기 위해 비슷한 게시물을 사용했지만 경고는 계속 발생합니다. 라인 (363) 및 (364)의 주위에 그 블록에서경고 : 형식 '% d'은 (는) 'int'유형을 필요로하지만 인수 4는 'size_t'유형입니다.
$ 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’
: 내가 경고를 제거해야합니까
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);
}
. 그것은 결과에 해롭다.
감사
마이클
당신은하지만'%의 zu'이 아닌 '%의 zd'를 할 것입니다 'size_t '는 부호없는 타입이다. –
와우 완전히 그 대답을 수정 해 주셔서 감사합니다 놓쳤습니다. – Nomad101
감사합니다. 너에게서 배웠다. –