Ask your own question, for FREE!
Computer Science 22 Online
OpenStudy (anonymous):

What is the difference between endl; and \n.

OpenStudy (opcode):

They are two different types: "\n" is a character constant, meanwhile "std::endl()" is a function. Performance wise \n better. This is because std::endl() flushes the stream after adding the new-line character, it also adds a new-line character to the out-put stream. Note: If you want to flush the stream instead of using std::endl() you can call std::cout.flush(). Here is a link: http://stackoverflow.com/questions/213907/c-stdendl-vs-n So in all there isn't much of a difference.

OpenStudy (opcode):

Also, Welcome to Openstudy. Enjoy your stay.

OpenStudy (e.mccormick):

And "std::endl()" can't be used inside quotes... so If you want a quick two line thing, you can do that inside a single thing: cout << "Please remember that capitalization matters!\nEnter your password here: " ;

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!