0
Endl does what? (C++)
5 Réponses
+ 4
http://www.cplusplus.com/reference/ostream/endl/
"Inserts a new-line character and flushes the stream. Its behavior is equivalent to calling os.put('\n') (or os.put(os.widen('\n')) for character types other than char), and then os.flush()."
The excess flush slows down your programs, so in many of my codes I only "endl" once -- at the end (+50% output or more)
https://code.sololearn.com/cRjbtysU5r3o/?ref=app
Same strategy applies to Python (there I gather all output in a variable, then print once)
+ 1
So... it sounds like
it adds a special character
(that functions as a delimiter)
that's equivalent of \n
("new line" function)
and then a flush
(syncing of internal stream data with external)
and
slow-downs come from the syncing
because it has to read all data stream
and that takes the time
(and above 4000 characters takes more time)
0
Found my answer by tapping on the text.
Turns out the UI in SoloLearn will show you "hints" aka descriptions if you press on an underlined text within program examples. Such as the C++ "Working with Variables" section.
If someone has a technical answer of what endl does under the hood, or just needs a question to answer, it would still be appreciated :D
It was stated as a macro for \n
(in a different answer to a related question)
Can someone elaborate?
(My apologies if this is a duplicate question)
0
Adds a specific symbol, which is interpretered as next line of text. ASCII table has the code for this symbol, but I can't remember it.
0
*interpreted as delimiter for lines of text
Sorry, my mistake.