Jul 18, 2011 at 7:38am UTC
Hello, I don't understand one thing in the following program,and I decided to ask you.
#include <iostream>
using namespace std;
#define PI 3.14159
#define NEWLINE '\n'
int main ()
{
double r=5.0;
double circle;
circle = 2 * PI * r;
cout << circle;
cout << NEWLINE;
return 0;
}
I didn't understand from the tutorial what exactly is newline '\n' and what exactly does.
Jul 18, 2011 at 8:20am UTC
newline makes a new line (like its name) in your program, for example:
this is a line
this is a line made in another line by making a new line in program...
Last edited on Jul 18, 2011 at 8:20am UTC
Jul 18, 2011 at 9:52am UTC
Think of the this way. Below, I've replicated an output buffer. Notice all of the characters within the buffer. Also, notice the \n (newline escape sequence).
'T', 'h', 'i', 's', ' ', 'i', 's', ' ', 'a', '\n', 'l', 'i', 'n', 'e', '.'
If I print this, the result should be like this:
This is a
line.
Notice how the newline escape sequence wasn't printed.
Wazzak