Carriage return \r
is used to mark cursor to the start line.But when below code is compiled in turbo c it gives different output than from an online compiler !
#include<stdio.h>
main()
{
printf("abcd\r123");
getch();
}
Output:
123d
Code used in online compiler :
#include <stdio.h>
int main(void) {
printf("abcd\r123");
return 0;
}
Output :
What is the correct output ? Im confused also whats the reason for that behavior? [In both cases
printf
produces same result !]
Some references that could not help me understand:
What are carriage return, linefeed, and form feed?
What is the difference between a "line feed" and a "carriage return"?