Title self explainitory
I've been trying to create a population of individuals each of which contains a string/or array of numbers.
For example: Individual A: 110010101101
then basically * 100 to get 100 copies.
I need to be able to call each individual and then call each element of the individual so i can mutate them.
here is what i tryed out:
Output is our Individual, and contains 21 int's of (1,0)Code:void GetPopulation(int (&Output)[21], int (&Pop)[PopSize][21]) { int index; int j; for ( index = 0; index < PopSize; index++) { for ( j = 0; j < 21; j++) { int Out; Out = Output[j]; Pop[index][j] = Pop[index][Out]; cout << Pop[index][j]; cin.get(); } } }
I was hoping the code would populate 100 arrays Pop[index]
each of which would contain a copy of the original individual
Pop[j].
Then try and print out what is in the arrays: ie
Pop[1st ind][1-21] = "01010101010101" etc
then on to the next ad infinitum.
Sadly it only prints out "0" then crashes at the end
Output and Pop are both declared in Main()
int Pop[PopSize][21];
Popsize is defined as 100
Is there anything grossly wrong,
And i understand that there maybe better ways of doing it, ie someone suggesting Vectors etc but until i learn about them i'd rather stick with plain old arrays
Unless i fundementally have to change it
Thanks for any help
Regards Wolfe