Println! Macro VS print

I am going through the rust book and I am on chapter 3. I am bit confused what is the difference between the println and the normal print?

ln suffix refers to to "line". Macros with this suffix add a new line character (platform specific; \n on linux, \r\n on windows) to the message they emit.

To visualise this better, this can be best seen when you invoke print macro twice. If you run

println!("foo");
println!("bar");

the output will be

foo
bar

But if you run

print!("foo");
print!("bar");

then the output will look like this

foobar

The same is true for eprint and eprintln, which print to stderr as well as write and writeln, which print to passed write sink.

println!() and print!() are both macros, to allow arguments of different data types and number, and also formatting support. That would not be possible with ordinary Rust functions.

The difference between println! and print! is, that the former terminates the output with a newline character, so that multiple println! calls all generate output on different lines. However, the print! macro outputs only the arguments, without a terminating newline character, so that you can print multiple arguments onto one line. E.g. you might use a few print! calls, followed by a println!, to finally skip to the next output line. However, as println! has formatting support for multiple arguments, the plain print! call is rarely required.

Thanks, this demonstrates it clearly, so the difference is println! macro prints to the screen with newline character after each println! and the other print! just prints without producing new line character or just simply it prints it's arguments in one line. Is that understanding of mine correct?!

Actually, a use case where you would need the plain print!() call is when you ask for input in a terminal application and want the user input their reply on the same line. That makes no difference for the actual behavior of the app, but might look nicer. The official tutorial book had a guessing game example at the beginning, which might use this input variant.

And note, that println! does not print a newline character after each argument value, but first processes all the arguments, and finally terminates the output by writing a newline character, moving the cursor to the next line!