Need help with "Visual C++ Express Edition"

Jan 21, 2008 at 2:56am
closed account (98hbqMoL)
I am trying to write a program that will display text on a screen. However, everytime I try to compile the code I get these messages:
"'cout' : undeclared identifier"
"'std' : is not a class or namespace name"

If it helps, this is the code I was using:

// Army Tank RPG.cpp : Defines the entry point for the console application.
// This is supposed to be a game about a grandfather who leaves behind his Tank Building Business to his grandson.

#include "stdafx.h"
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
std:: cout << "Welcome to ARMY TANK RPG!";
std:: cout << "This is a game about a grandson who leaves his tank building business to his grandson, which is you.";
std:: cout << "However, a gang of thiefs had been trying to pry the business from your grandfather for years.";
std:: cout << "It is up to you to help stop those bastards!";
return 0;
}

Can someone please give me more information about my errors?
Jan 21, 2008 at 2:58am
closed account (98hbqMoL)
NOTE: The program I'm currently building is just the information. Hopefully, when I get enough experience, I can actually make the program "Army Tank RPG."
Jan 21, 2008 at 6:29am
try #include <iostream> or <iostream.h>
and when using namespace std, I don't think you have to type std::cout.

and try to use int main() or int main(void)

I don't know what compiler you use, but with the one from Mircorsoft or the
one from Dev Bloodshed you should be ok with iostream and int main()

Jan 21, 2008 at 6:30am
you must add this directive
#include <iostream>

to work

EX.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
// Army Tank RPG.cpp : Defines the entry point for the console application.
// This is supposed to be a game about a grandfather who leaves behind his Tank Building Business to his grandson.

#include <iostream>
using namespace std;

int main()
{
         cout << "Welcome to ARMY TANK RPG!";
         cout << "This is a game about a grandson who leaves his tank building business to his grandson, which is you.";
         cout << "However, a gang of thiefs had been trying to pry the business from your grandfather for years.";
         cout << "It is up to you to help stop those bastards!";
return 0;
}

Last edited on Jan 21, 2008 at 6:35am
Jan 22, 2008 at 8:42pm
closed account (98hbqMoL)
Thanks, it worked!
:)
Topic archived. No new replies allowed.