我已经搜索过这个警告,每个人的代码都有一些错误,但这里有一些非常意想不到的东西,我无法弄清楚。我们确实希望 strlen(x) 是一个整数,但是这个警告告诉我什么?strlen 怎么不能是 int 呢?
In function ‘fn_product’:
line85:3:warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘size_t’ [-Wformat]
我在 fn_product 中的代码——
char *fn_product (char x[],char y[]){
if (strlen(x)==1) // line85
printf("\nlength of string--%d\n", strlen(x));
/*other code*/
}
strlen(x) 不应该是 int。为什么说它的格式是 size_t?