Problem using <iostream>

Hi all, I know basic C++ and am trying to relearn it.

I have got Visual Studio 2008.

I am trying to compile the following:

#include <iostream>

main ()
{
cout << "hi" << endl;
return 0;
}


However it tellsss me cout and endl are undeclared indetifiers.

I tried making iostream into iostream.h but this also failed to work, saying iostream.h could not be found. I remember having this problem previously and having to make additional libraries available in the project properties but can't remember what to do.

any ideas?
You forgot a using namespace std; somewhere, or two std::s in one line.

EDIT2: And I forgot to mention you forgot an int before your main.

-Albatross

EDIT: If there are 15 spots per true dalmatian and I could exchange one spot on a dalmatian without enough spots for one post, I'd have a cute Disney movie. Provided I had enough white dalmatians. And fully-grown dalmatians usually have more spots than that.
Last edited on
I have now included using namespace std;

and made the main() into an int main()
and this seems to work

just seems like the wrong way to program?
What's exactly wrong? You cannot compile the code or you can't see the program output?
The code compiles fine, and produces the correct output.

I just thought using

int main() was C and not C++?
Now I'm thinking how did I miss the
and this seems to work
...

I just thought using
int main() was C and not C++?
main() is C, int main() is C++
Ahh got it. I haven't coded in over a year.

Thanks.
Topic archived. No new replies allowed.