EmbLogic's Blog

problem in cursor control formatters

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????

 

One Response to problem in cursor control formatters

  1. nitin sharma says:

    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.

Leave a Reply to nitin sharma Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>