ok i am trying to make an inventory program with a max amount of spells, weapons, armor, and other items of 10. i want them all to be in the inventory and i want them to have a stick in weapons (for a little while until they buy something better), a fire spell in spells, an old robe in armor, and 2 different potions in items. but im not sure what to do exactly. i think that this is bout right but my compiler gives me errors. like
These lines have no effect whatsever; you are dereferencing the array called inventory, but not doing anything with it. Basically, reading a value from the array, and then just moving on, making no changes and doing nothing with the value you read (which is actually off the end of the array anyway, and would possibly cause a segfault at runtime).
maxSpells is an integer; the number 10. You're then trying to treat it like an array, and put the value "fire" into an element you're specifying with an uninitialised string instead of a number. This is nonsensical. The same for lines 15,16,17.
I think you need to step back and make sure you understand what an array is, and how to create and use them.
It's just your compiler telling you it doesn't know what to do with the instruction "const int [string];", remember that the normal behavior of "[]" is to let the compiler know that:
i. you're declaring an array, e.g char name[] = "cainen172";
or,
ii. you're specifying an array elements e.g string spells[5];//declare five variables named spells that can hold string values
also Moschops has already explain it:
maxSpells is an integer; the number 10. You're then trying to treat it like an array, and put the value "fire" into an element you're specifying with an uninitialised string instead of a number.
ooooohhhh i gets it now. THANX EVERYONE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! :)