player.zbran =(weapon)* malloc(31*sizeof(weapon));
Skusal som nieco taketo, bohuzial to nefunguje.
Uvital by som pomoc
player.zbran =(weapon)* malloc(31*sizeof(weapon));
Plz, ako cez ten malloc? postni code.
Taktiez ako to upravit potom ked chcem pouzivat pole?
int main()
{
player_st player[50];
player.zbran = new weapon;
player.zbran->weaponEquiped=1;
printf("%d", player[20].zbran->weaponEquiped);
system("pause");
return 0;
}
a je to korektne len cisto C?
Nemozem pouzivat ziadne nic z c++;
#include <stdio.h>
#include <stdlib.h>
typedef struct weapon
{
int weaponEquiped;
};
typedef struct player_st
{
char name[9];
weapon *zbran;
};
int main()
{
player_st player;
player.zbran->weaponEquiped=1;
printf("%d", player.zbran->weaponEquiped);
system("pause");
return 0;
}