invalid types 'char[int]' for array subscript

Hello all,

So I was continuing my little text based adventure game, and I ran into a pinch.
The code has gotten too big to post here, so here's the link to the codepad. http://codepad.org/1eUjSi5z

I ran that into codepad, and now I got an error like so:

In function 'int main()':
Line 52: error: invalid types 'char[int]' for array subscript
compilation terminated due to -Wfatal-errors.



Any ideas?
You defined heshecaps as a single character. So you may not use the subscript operator with this variable.

char heshecaps;
You need to declare heshecaps as a pointer or an array, right now line 11 you declared it as a single char so you don't have an array to access on lines 52-53.
http://codepad.org/8GDUvyK2

I made some touch-ups, how about now?
Firstly this comparison is incorrect from the logical point of view. It will be always equal to true because expression "girl" is not equal to zero.
if (gender == "woman" || "girl")

I think you meant

if (gender == "woman" || gender == "girl")

Also arrays have no the assignment operator. So the code below is invalid.

{heshe = "she";
heshecaps = "She";}

Instead you should use standard C function strcpy
Last edited on
Topic archived. No new replies allowed.