Original Post
I am using MSVC++ 6.0 trial version and I am trying to better my skills at C++ by making a little text-based RPG. Right now, I am working on the battle engine, and I am strings to hold the player’s and the monsters’ names. I am having a lot of errors come up saying that the string data type is undefined, even though I have included the STRING.H file. This is the code from the file that these errors are arising:
#include "iostream.h"
#include "string.h"
//DATA TYPES
struct character
{
string name;
short maxhp;
short maxmp;
short atk;
short amr;
short agi;
short str;
short def;
};
//CHARACTERS
character you =
{
youname,
100,
0,
4,
0,
80,
5,
0
};
//MONSTERS
character gnome =
{
GNOME,
100,
0,
3,
0,
75,
5,
0
};
And here are some of the errors I am getting:
error C2146: syntax error : missing ';' before identifier 'name'
error C2501: 'string' : missing storage-class or type specifiers
error C2501: 'name' : missing storage-class or type specifiers
error C2065: 'youname' : undeclared identifier
error C2078: too many initializers
error C2065: 'GNOME' : undeclared identifier
error C2078: too many initializers
error C2011: 'character' : 'struct' type redefinition
error C2374: 'you' : redefinition; multiple initialization
see declaration of 'you'
error C2078: too many initializers
error C2374: 'gnome' : redefinition; multiple initialization
see declaration of 'gnome'
error C2078: too many initializers
Edited by - Squeejee on October 11, 2001 10:23:16 PM