gpt4 book ai didi

c - 无论输入什么,答案都是 67,为什么?

转载 作者:行者123 更新时间:2023-11-30 20:10:59 24 4
gpt4 key购买 nike

#include <stdio.h>
#include <stdlib.h>

int main()
{
int a;
scanf("%*2s",&a);
printf("%d\n",a);
return 0;
}

输出:

1351 (input to scanf)
67 (output from printf)

无论我输入什么,答案总是 67。67 从哪里来?

最佳答案

从用户 user 获取 int 值:

int a;
scanf("%d",&a);

scanf 使用不同的说明符:

%d 个整数

%f float

%d 双

%c 字符

关于c - 无论输入什么,答案都是 67,为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42469943/

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