c - scanf() 跳过变量

标签 c scanf

在 C 语言中,使用带有参数的 scanf() 时,scanf("%d %*d", &a, &b) 的行为有所不同。它只输入一个变量的值,而不是两个!

Please explain this!

scanf("%d %*d", &a, &b);

最佳答案

* 基本上意味着忽略说明符(读取整数,但不赋值)。

引自man scanf :

 *        Suppresses assignment.  The conversion that follows occurs as
          usual, but no pointer is used; the result of the conversion is
          simply discarded.

关于c - scanf() 跳过变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39710316/

相关文章:

c - 对 'explain_setsocket' 的 undefined reference

c - sscanf 替换以前的值

c - 当我 scanf(%s,lastName); 时遇到段错误(正文代码在里面)

c - scanf 整数变量之间的 scanf char 变量不起作用?

c - 如何在fopen中获取用户输入

c - 你怎么能告诉计算机它正在添加而没有 addl 在程序集中

c - 如何使用C在Linux中获取已安装驱动器的卷名?

c - SWIG - 使用 %newobject 的垃圾收集

c - 奇怪的 printk 对 linux 堆栈大小测试的影响

c - 读取 int 类型时如何不读取 scanf 中的 float 类型