Problem using <iostream>

Sep 23, 2010 at 6:25pm
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?
Sep 23, 2010 at 6:28pm
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 Sep 23, 2010 at 6:32pm
Sep 23, 2010 at 6:31pm
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?
Sep 23, 2010 at 6:38pm
What's exactly wrong? You cannot compile the code or you can't see the program output?
Sep 23, 2010 at 6:40pm
The code compiles fine, and produces the correct output.

I just thought using

int main() was C and not C++?
Sep 23, 2010 at 6:47pm
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++
Sep 23, 2010 at 6:48pm
Ahh got it. I haven't coded in over a year.

Thanks.
Topic archived. No new replies allowed.