Need Help

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
RandomDever
Chaos Rift Regular
Chaos Rift Regular
Posts: 198
Joined: Thu Mar 26, 2009 8:42 pm
Current Project: My Engine
Programming Language of Choice: C++

Need Help

Post by RandomDever »

Okay here's the whole program I wrote.

Code: Select all

#include <iostream>

void main()
{
	cout << "WTF?????";
}
I'm using Microsoft Visual C++ 2008
Here's the error:
main.cpp(5) : error C2065: 'cout' : undeclared identifier
What did I do wrong????? :|
User avatar
Ginto8
ES Beta Backer
ES Beta Backer
Posts: 1064
Joined: Tue Jan 06, 2009 4:12 pm
Programming Language of Choice: C/C++, Java

Re: Need Help

Post by Ginto8 »

you may want to make

Code: Select all

void main()
into

Code: Select all

int main()
and add a

Code: Select all

return 0;
at the end of it.

As for the problem with cout... I have no idea. :shock2:
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
User avatar
Maevik
Chaos Rift Junior
Chaos Rift Junior
Posts: 230
Joined: Mon Mar 02, 2009 3:22 pm
Current Project: www.keedepictions.com/Pewpew/
Favorite Gaming Platforms: PC
Programming Language of Choice: C++
Location: Long Beach, CA

Re: Need Help

Post by Maevik »

cout ( as well as cin , endl etc... ) is part of the namespace "std"
Therefore, in order to use it you must either use the namespace:

Code: Select all

using namespace std;
or use the identifier std::cout;

It should work as:

Code: Select all

#include <iostream>

using namespace std;

void main()
{
   cout << "WTF?????";
}
or:

Code: Select all

#include <iostream>

void main()
{
   std::cout << "WTF?????";
}
Last edited by Maevik on Sun Apr 05, 2009 9:19 pm, edited 1 time in total.
My love is like a Haddoken, it's downright fierce!
RandomDever
Chaos Rift Regular
Chaos Rift Regular
Posts: 198
Joined: Thu Mar 26, 2009 8:42 pm
Current Project: My Engine
Programming Language of Choice: C++

Re: Need Help

Post by RandomDever »

Sorry Maevik..
I'm fucking retarded.
I forgot I'm not using codeblocks any more.
User avatar
Maevik
Chaos Rift Junior
Chaos Rift Junior
Posts: 230
Joined: Mon Mar 02, 2009 3:22 pm
Current Project: www.keedepictions.com/Pewpew/
Favorite Gaming Platforms: PC
Programming Language of Choice: C++
Location: Long Beach, CA

Re: Need Help

Post by Maevik »

heh, I just like when someone has an easy question that I may actually know the answer to :D
My love is like a Haddoken, it's downright fierce!
Post Reply