-
February 6th, 2003, 05:59 AM
#1
C++ newbie q
My question is should I end my output lines with std::end1 or '\n' and why?
-
February 6th, 2003, 06:28 AM
#2
\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.
Bukhari:V3B48N826 “The Prophet said, ‘Isn’t the witness of a woman equal to half of that of a man?’ The women said, ‘Yes.’ He said, ‘This is because of the deficiency of a woman’s mind.’”
-
February 6th, 2003, 06:31 AM
#3
Senior Member
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.
Ben Franklin said it best. \"They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.\"
-
February 6th, 2003, 06:31 AM
#4
Junior Member
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.
-
February 6th, 2003, 06:49 AM
#5
I've learned C++ rather crudely on my own.. so this is probably horribly wrong, but i always use. cout << "Text Goes Here" << endl
-
February 6th, 2003, 07:15 AM
#6
Senior Member
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.
\"I have a 386 Pentium.\"
-
February 6th, 2003, 08:19 AM
#7
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.
-
February 6th, 2003, 09:14 AM
#8
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.
S25vd2xlZGdlIGlzIHBvd2VyIQ
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|