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

标签 c stdio

#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/

相关文章:

c - 执行 while 循环或 while 循环

c - 是否可以使用循环来声明变量?

在c中连接两个单独字符串的大写字母

c - 通过 C 中的 void 函数返回动态数组

c - 如何通过重定向接受命令行参数

c - 当您不知道缓冲区大小时如何避免危险的 vsprintf

基于C中不均匀范围的计算量

linux - stdio 通信的安全性

c - 如何在c中的#define指令中传递值?

c - 有没有办法在 C 中增量处理格式说明符字符串?