Jump to content
  • Advertisement
Sign in to follow this  
Shewolf

Question about seperate files

This topic is 4353 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I made a header file named Globals.h to put all my global variables in and declare my functions. Well when I compile it useing bloodshed it gives me: Globals.h no such file and then says my variables arent being declaired.
// MAIN

#include <iostream>
#include "Globals.h"
using namespace std;

int playercharacter();
int PName();  
int Gender(); 
int Race();
int Profession();
int Human();
int Elf();
int Dwarf();
int Warrior();
int Wizard();
int Cleric();


int main()
{
    bool charactersetup = false;
    if(charactersetup == false)
    {
        cout << " Welcome to Kesmere\n\n\n ";
        PName();
        Gender();
        Race();
        Profession();
        charactersetup = true;
    }    
    else
    {
    }    

    system("pause");

    return 0;
}

int PName()
{
    char name[50];

    cout << " Enter your name\n\n";
    cin >> name;
    cout << " You have chosen to be known as " << name << ".\n\n";
}  

int Gender()
{
    int gender;
    string gendername;
    cout << " Please choose your gender\n";
    cout << "1. Male" << endl;
    cout << "2. Female\n\n";  
    cin >> gender;
    if(gender == 1)
    {
        gendername = "male";
        cout << "You have chosen to play as a " << gendername << endl;
        
        
    }
    else
    {
        gendername = "female";
        cout << "You have chosen to play as a " << gendername << "\n\n";
    }       
    
}    

int Race()
{
    int rchoice;
    
    cout << " Please chose:\n";
    cout << " 1. human " << endl;
    cout << " 2. elf " << endl;
    cout << " 3. dwarf " << endl;
    cin >> rchoice;
    
    switch(rchoice)
    {
        case 1:
            Human(); 
            break;
        case 2:
            Elf(); 
            break;
        case 3:
            Dwarf(); 
            break;    
    }    
    
}    

int Profession()
{
    int pchoice;
    
    cout << " Please chose:\n";
    cout << " 1. warrior " << endl;
    cout << " 2. wizard " << endl;
    cout << " 3. cleric " << endl;
    cin >> pchoice;
    
    switch(pchoice)
    {
        case 1:
            Warrior(); 
            break;
        case 2:
            Wizard(); 
            break;
        case 3:
            Cleric(); 
            break;    
    }    
    
}    



int Human()
{
    string race = " human ";
    hp = 10;
    dex = 8;
    mana = 6;
    
    cout << "You have chosen to play as a" << race << "." << "\n\n";
    cout << " You now have:" << endl;
    cout << " Hit Points: " << hp << endl;
    cout << " Dexterity: " << dex << endl;
    cout << " Mana: " << mana << "\n\n";
}    

int Elf()
{
    string race = " elf ";
    hp = 9;
    dex = 7;
    mana = 10;
    cout << "You have chosen to play as a" << race << "." << "\n\n";
    cout << " You now have:" << endl;
    cout << " Hit Points: " << hp << endl;
    cout << " Dexterity: " << dex << endl;
    cout << " Mana: " << mana << "\n\n";
} 

int Dwarf()
{
    string race = " dwarf ";
    hp = 12;
    dex = 9;
    mana = 5;
    cout << "You have chosen to play as a" << race << "." << "\n\n";
    cout << " You now have:" << endl;
    cout << " Hit Points: " << hp << endl;
    cout << " Dexterity: " << dex << endl;
    cout << " Mana: " << mana << "\n\n";
} 

int Warrior()
{
    string profession = " warrior ";
    cout << "You have chosen to play as a" << profession << "\n\n";
}    

int Wizard()
{
    string profession = " wizard ";
    cout << "You have chosen to play as a" << profession << "\n\n";
}

int Cleric()
{
    string profession = " cleric ";
    cout << "You have chosen to play as a" << profession << "\n\n";
}        

and here is my global.h code
#include <iostream>
using namespace std;

int hp;
int dex;
int mana;

Share this post


Link to post
Share on other sites
Advertisement
The error message can only mean two things:
  • The file is not present in the same directory as the including file
  • The file is present, but cannot be read

    Therefore, I can only suggest that you check the existence of the two files, and the access rights for the header file.

    Share this post


    Link to post
    Share on other sites
    With an 's' at the end, or without? Thus far you've said both "Globals.h" and "global.h".

    Share this post


    Link to post
    Share on other sites
    Ok, I reads the article it was hepful, but I didnt understand a few things. unfortunatly I'm having the same problem. I tried useing ms visual and it worked fine, but it wont work on bloodshed. :/

    Share this post


    Link to post
    Share on other sites
    Mmm...it won't work in Dev, but it will in Visual? That seems weird.


    Why don't you just use Visual then? IMO it is a lot better IDE, and it has a very nice Debugger.


    Chad.

    Share this post


    Link to post
    Share on other sites
    Sign in to follow this  

    • Advertisement
    ×

    Important Information

    By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

    We are the game development community.

    Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

    Sign me up!