我的第二个 scanf
在此代码中不起作用,计算机不会等待我输入第二个值。
我知道什么时候会发生 %c
只需要在 %
之前放一个空格
但不能让它与 %f
一起工作
#include <stdlib.h>
#include <stdio.h>
main()
{
float a, p;
printf("Insira seu peso: "); scanf("%.1f", &p);
printf("Insira sua altura: "); scanf("%.2f", &a);
}
最佳答案
点 .
不是 scanf()
中的有效格式标志字符函数族。格式与 printf()
相关格式家族(这不是偶然的),但它们远非相同。
Each conversion specification is introduced by the character '
%
' … after which the following appear in sequence:
An optional assignment-suppressing character '
*
'.An optional non-zero decimal integer that specifies the maximum field width.
[CX] ⌦ An optional assignment-allocation character '
m
'. ⌫An option length modifier that specifies the size of the receiving object.
A conversion specifier character that specifies the type of conversion to be applied. The valid conversion specifiers are described below.
没有提及
.
在那里。
关于c - 我的第二个 scanf 不起作用 - 我该怎么办?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60255319/