我试图通过
scanf
函数从用户输入中获取 2 个整数,并使用 printf
打印出该输入。不知何故,我无法打印出第二个整数。我在这里错过了什么?
#include <stdio.h>
#include <math.h>
int main (void)
{
unsigned long long int x = 0, y = 0;
printf("The first integer: ");
scanf("%llu", &x);
printf("x is %llu\n", x);
printf("The second integer: ");
scanf("%llu\n", &y);
printf("y is %llu", y);
}
我尝试仅从
printf("The second integer: ")
运行代码,但程序无法按预期打印出 y
的用户输入。
由于您使用的是 math.h 库,请确保在编译代码时使用 -lm 标志。此外,第二个 scanf 函数中的占位符之前应该有一个空格,您可以在其中收集整数 y 的输入,并确保没有换行符。