I'm trying to create an RPG-esque inventory, my inventory contains a type 'sword' which is an array. Here's the code for my sword struct:
typedef struct
{
char weaponName[35];
int damage;
int rarity;
float price;
} sword;
Here's the one for the inventory:
typedef struct
{
sword SwordInvent[size];
} inventory;
I tried to initialize the SwordInvent array in the main function but it ends up with an error.
[Error] expected expression before '{' token
main()
{
inventory inv;
inv.SwordInvent[0] = {"Paper Sword", 1, 1, 1};
}
Can anyone be kind enough to help me get out of this hole? :(
EDIT I could not thank you all enough! I wasn't really expecting to get this much of help! Seriously, thank you!
inventory inv = {{"Paper Sword",1,1,1}}.