can someone tell me what is "endl" in C++ . i googled it and found all kind of technical and mechanical explanations :-\ so can someone please tell me this in a human understandable form ? please ? Thanks in advance
Hey Neon32 are you learning C++ in class or are you just trying to learn to use it by yourself...? they are teaching C++ in my class now....i learned C, SQL & Java Netbeans in my last semester.... going to learn Oracle too this sem,have no idea what that is though... Im soo excited, by the end of college im gonna learn half of the best Programming languages out there...
oracle is a database system. I'm somewhat surprised you've been taught both C and C++ considering C++ has pretty much replaced C.
Yeah had to learn C too... I keep writing "printf" and "scanf" instead of "cout" and "cin".... Happens to me everytime... I think C was taught for us to get an idea how C++ works...
Both "\n" and "endl" works. And yes, you can have multiple lines displayed with a single "cout" command through the use of "endl". Example: cout << "This is the first line." << endl << "This is the second line." << endl << "This is the third line" << endl;
i tried this on my own and didnt found much difference between \n or endl; . thanks for all those who replied to it
I am not very familiar with C/C++, however it is possible that there is actually a difference between \n and endl. Basically there are multiple ways of ending a line, and different OSes use different methods. *nix uses a linefeed character (ASCII character 10) while Windows uses two characters, carriage return (ASCII character 13), followed by a linefeed (ASCII character 10), which is why neither can properly open files created by the other without the file being converted first. In PHP, \n produces a linefeed, whereas on Windows you would need to use \r\n in order to get the line break, and other OSes use other combinations. This makes it hard to write portable PHP code, so we have an alternative, PHP_EOL, which produces whichever line ending the host system uses. C++'s endl may be similar to PHP_EOL in that it is portable and its output is dependent on the target system. EDIT: clarification