[英]Too many arguments for format (printf function)
Keep getting the following warning: “too many arguments for format” for the printf function below.不断收到以下警告:下面 printf 函数的“格式参数太多”。 Do not know what is causing this warning.
不知道是什么导致了这个警告。 I provided the type values of pos and str_pos along with the printf function.
我提供了 pos 和 str_pos 的类型值以及 printf 函数。 I excluded all other code as I did not think it was necessary for this question.
我排除了所有其他代码,因为我认为这个问题没有必要。
int pos;
char str_pos;
printf("The character at index %d is %c",pos,str_pos, "\n");
The corect way of writing that printf()
statement would be编写
printf()
语句的正确方法是
printf("The character at index %d is %c\n", pos, str_pos);
You need to change你需要改变
“
to "
s. “
到"
s。pos
and string_pos
as the argument (not part of the format string itself), in the variadic list.pos
和string_pos
作为参数(不是格式字符串本身的一部分)。 Also, I presume that variables are initialized before you're printing them.另外,我假设变量在打印之前已经初始化。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.