Error in code

Why does not this code work correctly?
1
2
3
4
5
6
7
 i1 = glosa->Count;
 srand (time(NULL));
			 if(i1%2 != 0){
			 i1+=1;
			 i1 = rand()% glosa->Count;
			 tbx_SvarSv->AppendText(glosa[i1]);
 }
Last edited on
Where and what is the error?

What is the type of glosa?
The error is a index error when I try to use the loaded program. No error message is located before its done building.

glosa is a list of strings.
Is glosa properly created even if the array size is 0?

You cannot access field 0 if the array size is 0.
Topic archived. No new replies allowed.