gpt4 book ai didi

c - printf 返回 32676。请让我理解为什么以下输出不是 11

转载 作者:行者123 更新时间:2023-11-30 18:35:30 25 4
gpt4 key购买 nike

    #include<stdio.h>
void main()
{
int a,b,p;
printf("Enter values of a and b");
scanf("%d%d", &a, &b);
p=printf("a=%d b=%d p=%d",a,b, p);
}

这是我的问题的代码。将输入视为 a=2 和 b=3。

最佳答案

更改:

p=printf("a=% b=%d p=%d",a,b, p);

至:

p = printf("a=%d b=%d\n", a, b); // <<< fix format string
printf("p=%d\n", p); // <<< print `p` *after* you have assigned a value to it

请从今天起启用编译器警告 - 任何好的编译器都会在编译时向您指出上述所有错误。

关于c - printf 返回 32676。请让我理解为什么以下输出不是 11,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46589439/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com