假设我有要求用户提供2个整数的代码,当用户提供整数时,程序将打印总和。

int main(void)

{
printf("Please give me an int: ");
int x = GetInt();

printf("Please give me an int: ");
int y = GetInt();

printf("%d\n", x + y);
}


当我运行程序时,所有三个printf都显示在单独的行上。

我的问题:我不明白的是为什么前两个printf不需要\ n才能移到新行,而第三个printf确实需要\ n。

最佳答案

前两个的\n由用户在输入号码后按Enter键时提供。

关于c - GetInt()是否在此处自动创建\n输出?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30539483/

10-16 20:10