scanf() 跳过变量

编程入门 行业动态 更新时间:2024-10-28 13:25:03
本文介绍了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!

Please explain this!

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

解决方案

The * basically means the specifier is ignored (integer is read, but not assigned).

Quotation from man scanf:

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

更多推荐

scanf() 跳过变量

本文发布于:2023-11-24 10:13:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1624794.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:变量   跳过   scanf

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!