What is the difference between endl; and \n.
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.
Also, Welcome to Openstudy. Enjoy your stay.
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: " ;
Join our real-time social learning platform and learn together with your friends!