c++ issue

xox

Joined Sep 8, 2017
936
May I know what happen to my code when compile I get error ?

View attachment 301355View attachment 301356
Well, you are trying to iterate ten times through an array that only contains 8 elements. You can use 'sizeof(members_list)/sizeof(members_list[0])' to calculate the number of elements at compile time. Just remember that it is only valid to do so with so-called "local-scope arrays". (Which is to say, arrays declared at or above the level that the sizeof(x)/sizeof(x[0]) expression appears).

Also, why are you incrementing the pointer at 'members_list[index]'?
 

xox

Joined Sep 8, 2017
936
View attachment 301403
The iteration looks like it goes over elements 0 to 9 in an array with 10 elements.
Yes I overlooked that bit, didn't I? Thanks for the correction. (Serves me right for answering question before coffee!)

Anyway, now that I can actually think straight...

The main problem is that member_list is partially uninitialized. Indexes 0, 5, 7, 8, and 9 should be pointing to something. (Maybe set the string at index 0 to "***UNINITIALIZED***" or what have you to serve as the default value?)
 

djsfantasi

Joined Apr 11, 2010
9,237
What are you trying to do in this line

member_list[index]++;

You are trying to increment a string variable. I don’t know what that means.
 
Top