the difference between \r and \n

Y

YarvinG Liu

i write two codes:
printf("123\r");
printf("123\n");
the lattar. as we all know. the output will be:
123
press any key to continue

but the formmer will be:
press any key to continue

which means data:123 has lost.
Y?
 
D

Dan

YarvinG Liu said:
i write two codes:
printf("123\r");
printf("123\n");
the lattar. as we all know. the output will be:
123
press any key to continue

but the formmer will be:
press any key to continue

which means data:123 has lost.
Y?

\r move the cursor back to the start of the line, the "press any key.." is
then written over the top of 123. Its probably safest to always go \r\n if
you are on windows systems.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,781
Messages
2,569,619
Members
45,317
Latest member
Thompson Mark

Latest Threads

Top