Both of the snippets function "normally". The difference is that the first snippet flushes the output buffer each time because of the endl, while the second snippet only flushes the output buffer once at the end of the program when the stream is destructed.