Newbie error

I've just started doing some c++ in preperation for uni and I'm stuck over a very simple matter.

How come this first code doesn't work while the second one does? I've testet without the "endl" in the first one and then it works fine. The problem seems to be when I use "std" in combination with the "endl"

The build message says "error: ´endl´ was not declared in this scope"

1
2
3
4
5
6
7
#include <iostream>

int main ()
{
    std::cout << "Hello World" << endl;
    std::cout << "Hello World";
}


1
2
3
4
5
6
7
8
9
#include <iostream>

using namespace std;
int main ()
{
    cout << "Hello World" << endl;
    cout << "Hello World";
}


Would appreciate an easy explanation to what I'm doing wrong here.

~LtMoe
In the first one you need to include the std:: prefix on endl as you have on the cout there.
Oh my GOOD!! You are pure genious man!

Thanks alot!! :D
Topic archived. No new replies allowed.