gpt4 book ai didi

c - scanf() 跳过变量

转载 作者:行者123 更新时间:2023-11-30 16:56:58 25 4
gpt4 key购买 nike

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

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