-2

The program runs but every time I do it just ends up crashing it after. I also get "Segmation Fault" Error when running a debug

         enemy mob[2];

         for(i=0; i<2; i++){

            mob->mobAttack[i] = 25;
            mob->mobHealth[i] = 150;
            mob->mobName[i] = "Growler";

        } 

Structure

typedef struct{

char * mobName;
int * mobHealth;
int * mobAttack;

} enemy;

1 Answers1

1

you need

    typedef struct{

    char * mobName;
    int  mobHealth;
    int  mobAttack;
} enemy

and

  mob[i].mobAttack = 25;

etc. I assume the compiler was complaining big time at you , dont ignore warnings

pm100
  • 48,078
  • 23
  • 82
  • 145