小编bza*_*zal的帖子

%zd说明符是C11中的可选功能吗?

我使用了一个非常简单的代码:

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);
}  
Run Code Online (Sandbox Code Playgroud)

但是,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
Run Code Online (Sandbox Code Playgroud)

我的书也直接演示了上面的例子,但没有提到它是某种特殊的格式说明符,如果要包含库文件的话.即使是在线编译器也没有产生正确的结果.为什么代码不起作用?

c scanf format-specifiers c11

0
推荐指数
1
解决办法
978
查看次数

标签 统计

c ×1

c11 ×1

format-specifiers ×1

scanf ×1