'\r' is used to get the cursor to the first character.If you write any character after the '\r' then those characters will overwrite the characters from the first character in the line.
Consider the following example,
Here I want to print the number count and I have to print the numbers in one line.In this case I can use '\r'.Because after printing the count just go to the first position and then print the next count.
fprintf(stderr,"The number is %d\r" ,i);
Since ,because of the buffer problem I used fprintf ,because to solve the buffer problem I need "\n" in printf.