我已经使用了一个非常简单的代码:CZ中的%zd说明符是否为可选功能?
int main(void)
{
size_t variable;
/*prompt*/
printf("enter the value of the variable: ");
scanf("%zd", &variable);
printf("you entered %zd value of the variable", variable);
}
Howeve,GCC编译器产生以下结果:
Enter the vale of the size_t variable: 15
You entered zd value of size_t type
Process returned 35 (0X23) execution time: 3.094s
Press any key to continue
我的书也证明了上述例子的情况下直接提的是,它是某种一个特殊的格式说明符,如果库文件被包含在内。 即使the online compiler也没有产生正确的结果。 为什么代码无法正常工作?
因为您调用'printf'而不传递说明符的参数。 – StoryTeller
如果你打开了更多的警告,你会发现你将'variable'的* value *而不是* address *传递给'scanf()'。 –
[如何使用\“printf()\'?]使用”zd“说明符的可能的重复项(http://stackoverflow.com/questions/32916575/how-to-use-zd-specifier-with-printf) – Jayesh