C中无警告输出size_t的值

  虽然警告没什么关系,吾能去掉的都尽量去掉。比如以下代码编译有警告:

printf("responsed %u:%s\n", strlen(response), response);


gh_http.c:288:12: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 2 has type ‘size_t {aka long unsigned int}’ [-Wformat=]
     printf("responsed %u:%s\n",strlen(response),response);

  怎么解决?改为%zu即可。

printf("responsed %zu:%s\n", strlen(response), response);

猜你喜欢

转载自blog.csdn.net/quantum7/article/details/84797063