c编程中的回车显示不同的输出

时间:2015-10-27 04:55:24

标签: c

回车 \r用于将光标标记到起始行。但是当下面的代码在turbo c中编译时,它提供的输出与在线编译器不同!

#include<stdio.h>
main()
{
printf("abcd\r123");
getch();
}

输出:

123d

在线编译器中使用的代码:

#include <stdio.h>

int main(void) {

     printf("abcd\r123");

    return 0;
}

输出

enter image description here

  

正确的输出是什么?我也很困惑,原因是什么   那种行为? [在这两种情况下printf产生相同的结果!]

有些参考文献无法帮助我理解:

What are carriage return, linefeed, and form feed?

What is the difference between a "line feed" and a "carriage return"?

0 个答案:

没有答案