#include <stdio.h>
void main()
{
printf("ab");
printf("\bsi");
printf("\rha");
}
this code gives the result "ha" in the GCC 4.8 compiler
#include <stdio.h>
void main()
{
printf("ab");
printf("\bsi");
printf("\rha");
printf("\n");
}
this code gives the output of "hai" in the GCC 4.8 compiler
Now the question arises as to why the output changes from "ha" to "hai" only when adding the expression printf ("\ n"); at the end, which (for me) should not affect the code due to previous lines.
source
share