回车 \r
用于将光标标记到起始行。但是当下面的代码在turbo c中编译时,它提供的输出与在线编译器不同!
#include<stdio.h>
main()
{
printf("abcd\r123");
getch();
}
输出:
123d
在线编译器中使用的代码:
#include <stdio.h>
int main(void) {
printf("abcd\r123");
return 0;
}
输出
正确的输出是什么?我也很困惑,原因是什么 那种行为? [在这两种情况下
printf
产生相同的结果!]
有些参考文献无法帮助我理解:
What are carriage return, linefeed, and form feed?
What is the difference between a "line feed" and a "carriage return"?