本文介绍了scanf() 跳过变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 C 中,将 scanf()
与参数一起使用,scanf("%d %*d", &a, &b)
的作用不同.它只为一个变量而不是两个变量输入值!
请解释一下!
scanf("%d %*d", &a, &b);
解决方案
*
基本上意味着忽略说明符(整数被读取,但未分配).
引自man scanf:
* 禁止赋值.接下来的转换发生为通常,但没有使用指针;转换的结果是干脆丢弃了.
In C, using scanf()
with the parameters, scanf("%d %*d", &a, &b)
acts differently. It enters value for just one variable not two!
scanf("%d %*d", &a, &b);
解决方案
The *
basically means the specifier is ignored (integer is read, but not assigned).
Quotation from man scanf:
这篇关于scanf() 跳过变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!