1. ## console game

Hey everyone. I am currently working on my first game, a simple console text-based battle game. Well actually I just started it today and have already run into serveral obstacles. Here is the code so far
Code:
```#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <fstream.h>

using namespace std;
struct character
{ int hp;
int att;
int def;
int acc;
int eva;
int randomhit;
int hitdamage;};
int main()
{
ofstream a_file ( "explaination.txt" ); //opens explanation file

character player;
character enemy;

player.hp=500;
player.att=50;
player.def=45;
player.acc=25;
player.eva=12;
player.randomhit=rand()%18;
player.hitdamage=rand(45)%55;

enemy.hp=300;
enemy.att=35;
enemy.def=42;
enemy.acc=15;
enemy.eva=3;
enemy.randomhit=rand()%10;
enemy.hitdamage=rand(30)%45;

cout<<"You : "<<player.hp<<"";
cout<<"Enemy : "<<enemy.hp<<"";

cout<<"Will you....\n";
cout<<"1) Attack\n2) Defend\n";

return 0;
}```
This is just the beggining and I know it's only very simple but once I get this one sorted I'll move on to more complexed games and then graphics, but back to the problem at hand :

Can someone please tell me why these error messages appear and how to fix them : (please)

54 C:\PROGRAM FILES\DEV-CPP\include\c++\3.3.1\bits\stl_algobase.h:67, from C:\PROGRAM FILES\DEV-CPP\include\c++\3.3.1\memory In file included from C:/PROGRAM FILES/DEV-CPP/include/c++/3.3.1/bits/stl_algobase.h:67, from C:/PROGRAM FILES/DEV-CPP/include/c++/3.3.1/memory

48 C:\PROGRAM FILES\DEV-CPP\include\c++\3.3.1\memory:54, from C:\PROGRAM FILES\DEV-CPP\include\c++\3.3.1\string from C:/PROGRAM FILES/DEV-CPP/include/c++/3.3.1/memory:54, from C:/PROGRAM FILES/DEV-CPP/include/c++/3.3.1/string

(There are more to this effect)

108 C:\PROGRAM FILES\DEV-CPP\include\c++\3.3.1\cstdlib `rand' not declared

27 C:\Program Files\Dev-Cpp\Templates\chrisbattle.cpp `rand' undeclared (first use this function)

2 C:\PROGRAM FILES\DEV-CPP\include\c++\3.3.1\backward\backward_warning.h: 32 #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated.

C:\Program Files\Dev-Cpp\Templates\chrisbattle.cpp In function `int main()':

Thanks

2. also look to where it points to as well as the code above.

1. maybe you dont have the proper syn for using the function rand.

ofstream a_file;
a_file.open("explaination.txt" );

edit: forget all this i the debuged code is below =D

3. here is the corect code:
[tag]
Code:
```#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <fstream>

using namespace std;

struct character
{ int hp;
int att;
int def;
int acc;
int eva;
int randomhit;
int hitdamage;
};

int main()
{
ofstream outfile;
outfile.open( "explaination.txt" );//opens explanation file

character player;
character enemy;

player.hp=500;
player.att=50;
player.def=45;
player.acc=25;
player.eva=12;
player.randomhit=rand()%18;
player.hitdamage=rand()%55;

enemy.hp=300;
enemy.att=35;
enemy.def=42;
enemy.acc=15;
enemy.eva=3;
enemy.randomhit=rand()%10;
enemy.hitdamage=rand()%45;

cout<<"You : "<<player.hp<<"";
cout<<"Enemy : "<<enemy.hp<<"";

cout<<"Will you....\n";
cout<<"1) Attack\n2) Defend\n";
[/tag]

4. If you are compiling C++ code then,
Code:
```#include <stdlib.h>
//should be
#include <cstdlib>```
But I'm not sure that will correct your rand() problems

5. Just got what u said about look where it points too. I went to the include\c++\3.3.1.etc. folder and looked the files. It came up with a bunch of text that I don't understand at all. Changing the header seemed to get rid of a few problems but most of them still persist

6. what i wrote did give me a score of 0-0 =D

and it was compiled in the C++

his big error was
#include<fstream.h>
where is should be
#include<fstream>

as well for the rand() he tryed to pass it info like this rand(45);

7. Could it be that there's something missing in the header file(s) ?
Man, that would suck.........

8. i dont know about your header files you had one miss spelled if you copy the code i typed it should work