when i write the statement – printf(“hello\r..jackie\n..jp\n”); it gives the o/p
..jackie
..jp
but when i write the statement – printf(“hello\n..jackie\r..jp\n”); it gives the o/p
hello
..jpckie
why????
when i write the statement – printf(“hello\r..jackie\n..jp\n”); it gives the o/p
..jackie
..jp
but when i write the statement – printf(“hello\n..jackie\r..jp\n”); it gives the o/p
hello
..jpckie
why????
EmbLogic Research & Competency Development Labs
Phone: +91 9818467776, 8527567776, 9650467776
Email: info@emblogic.com
Copyright © EmbLogic Embedded Technologies Pvt. Ltd.
this is beacuse of the “\r” property in printf statement.
\r moves the cursor to the begining of the line and further printing keep erasing the previous data.
so when you execute “printf(“hello\r..jackie\n..jp\n”); ” hello is replaced by ..jackie
but when you execute “printf(“hello\n..jackie\r..jp\n”); ” only ..ja is replaced by ..jp. rest contents will remain same.