Converting Char to Int Problem

Pages: 12
'10' = Multi-character constant. Throws a compiler warning but still works.

Character literals are required, by the standard, to be 1 character in length (not empty, either). '10' is invalid and should be a compiler error, not just a warning.
Hence why it won't run the program...

Which is why I changed it to just 10 without the ' ' but it still ends up corrupt.
Which is why I changed it to just 10 without the ' ' but it still ends up corrupt.
This inventory[item_type]+=amount; must be inventory[item_type - 1]+=amount; // Note -1 since array starts with 0
There we go! Thx! Can you please explain why you need that - 1 in there though?
The first element in the array is inventory[0].
This is because it is equivalent to *(inventory+0).
An array in some ways is equivalent to a pointer to the first element.
makes sense, thx alot! :D
Topic archived. No new replies allowed.
Pages: 12