My question is should I end my output lines with std::end1 or '\n' and why?
Printable View
My question is should I end my output lines with std::end1 or '\n' and why?
\n moves the output to a new line, std::end1 not only starts a new line but flushes out the buffer.
ive never had occasion to use std::endl. not being a programmer by trade what i write never requires this.
i got in the habbit of ending with \n Ex. cout << a << '\n';
but you can do either. also you should'nt have to type std::endl if your using namespace std or a using dirrective such as using std::endl; . But i cant recall ever having to do that to use endl.
c++ style is really std:endl , but it really depends on the situation and doesn't matter that much.
everyone seems to like /n here, well I like std:endl and use it way more often.
I've learned C++ rather crudely on my own.. so this is probably horribly wrong, but i always use. cout << "Text Goes Here" << endl
No endl is a great way to keep the memory clean. The buffer, as Tedob1 said.
In turbo C++, i have to inlclude another header file, i'm not sure about what you are using.
What Tedob1 said is correct. I don't know about the rest of you but I use both 'endl' and '\n'.
\n (newline) is an escape sequence -- like a carriage return. It simply moves your cursor to the next line for printing. I use this a lot when I have some heavy formatting to do.
endl is a stream manipulator. It advances output to the next line and flushes the buffer.
Try checking out msdn you may find some of the answers to your questions there. :)
useing endl is like hitting enter on the keyboard it will send the cursor to the next line. to end a line being a int, float, cout, or cin statement im most cases use ; Ive only been in programming class for three weeks now and all my programs ended with ; even with the return 0; statement. only time i entered std was at the beginning where i entered
# include <iostream>
using namespace std;
int main ( )
hope I helped out.