I just started making a text-based RPG zombie game. I am getting strange errors that make no sense to me. I get the errors with Visual C++ Express 2012 and Visual Studio 2012 Express. Here's my code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
#include <iostream>
#include "stdafx.h"
#include "windows.h"
#include "string"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
string gender;
string name;
int health;
string weapon;
char choice1;
char choice2;
char choice3;
char choice4;
char choice5;
char choice6;
char choice7;
char choice8;
char choice9;
char choice10;
char choice11;
char choice12;
char choice13;
char choice14;
char choice15;
char choice16;
char choice17;
char choice18;
char choice19;
char choice20;
cout<<"Welcome to Zombie Horde Survival! In this world, zombies have infected\n";
cout<<"the entire world, aside from certain few survivors. You are one of them.\n";
Sleep(4000);
system("CLS");
cout<<"Before you set off to survive, let's learn a bit about you.\n";
cout<<"Are you\n";
cout<<"A. Male or\n";
cout<<"B. Female?\n";
cin>>choice1;
if (choice1="a" || "A")
{
gender="male";
}
else if (choice1="b" || "B")
{
gender="female";
}
else
{
cout<<"That is not a valid choice. Please try again.\n";
cin>>choice1;
if (choice1="a" || "A")
{
gender="male";
}
else if (choice1="b" || "B")
{
gender="female";
}
cout<<"Now that we've got that settled, what's is your name? If you have played before and have a \n";
cout<<"spawn code, you can type it here as well.\n";
cin>>name;
return 0;
}
|
Here's my errors:
1>------ Build started: Project: Zombie Horde Survival Game, Configuration: Debug Win32 ------
1> Zombie Horde Survival Game.cpp
1>c:\users\michael\documents\visual studio 2010\projects\zombie horde survival game\zombie horde survival game\zombie horde survival game.cpp(1): warning C4627: '#include <iostream>': skipped when looking for precompiled header use
1> Add directive to 'StdAfx.h' or rebuild precompiled header
1>c:\users\michael\documents\visual studio 2010\projects\zombie horde survival game\zombie horde survival game\zombie horde survival game.cpp(32): error C2065: 'cout' : undeclared identifier
1>c:\users\michael\documents\visual studio 2010\projects\zombie horde survival game\zombie horde survival game\zombie horde survival game.cpp(33): error C2065: 'cout' : undeclared identifier
1>c:\users\michael\documents\visual studio 2010\projects\zombie horde survival game\zombie horde survival game\zombie horde survival game.cpp(36): error C2065: 'cout' : undeclared identifier
1>c:\users\michael\documents\visual studio 2010\projects\zombie horde survival game\zombie horde survival game\zombie horde survival game.cpp(37): error C2065: 'cout' : undeclared identifier
1>c:\users\michael\documents\visual studio 2010\projects\zombie horde survival game\zombie horde survival game\zombie horde survival game.cpp(38): error C2065: 'cout' : undeclared identifier
1>c:\users\michael\documents\visual studio 2010\projects\zombie horde survival game\zombie horde survival game\zombie horde survival game.cpp(39): error C2065: 'cout' : undeclared identifier
1>c:\users\michael\documents\visual studio 2010\projects\zombie horde survival game\zombie horde survival game\zombie horde survival game.cpp(40): error C2065: 'cin' : undeclared identifier
1>c:\users\michael\documents\visual studio 2010\projects\zombie horde survival game\zombie horde survival game\zombie horde survival game.cpp(51): error C2065: 'cout' : undeclared identifier
1>c:\users\michael\documents\visual studio 2010\projects\zombie horde survival game\zombie horde survival game\zombie horde survival game.cpp(52): error C2065: 'cin' : undeclared identifier
1>c:\users\michael\documents\visual studio 2010\projects\zombie horde survival game\zombie horde survival game\zombie horde survival game.cpp(61): error C2065: 'cout' : undeclared identifier
1>c:\users\michael\documents\visual studio 2010\projects\zombie horde survival game\zombie horde survival game\zombie horde survival game.cpp(62): error C2065: 'cout' : undeclared identifier
1>c:\users\michael\documents\visual studio 2010\projects\zombie horde survival game\zombie horde survival game\zombie horde survival game.cpp(63): error C2065: 'cin' : undeclared identifier
1>c:\users\michael\documents\visual studio 2010\projects\zombie horde survival game\zombie horde survival game\zombie horde survival game.cpp(67): fatal error C1075: end of file found before the left brace '{' at 'c:\users\michael\documents\visual studio 2010\projects\zombie horde survival game\zombie horde survival game\zombie horde survival game.cpp(7)' was matched
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Please tell me why this won't compile. Thanks in advance!