#include <stdio.h>
void main()
{
printf("ab");
printf("\bsi");
printf("\rha");
}
this code gives the output of "ha" on GCC 4.8 compiler
#include <stdio.h>
void main()
{
printf("ab");
printf("\bsi");
printf("\rha");
printf("\n");
}
this code gives the output of "hai" on GCC 4.8 compiler
now the question is why does the output change from "ha" to "hai" just on adding the statement printf("\n"); at the end which (according to me) should not affect the code due to the preceding lines.