hi everyone,
I am having a trouble in my code. It gives the following error:
Incompatible types in assignment of 'int*' to int[6]
Here is my code:
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#define MAXGEN 2
#define MAXPOP 4
#define CHROM_LENGHT 24
#define MUTPROB 0.033
#define CRPROB 0.6
main()
{int oldpop[MAXPOP][24];
int (*ptk)[16][6];
float a;
int i,j,k,l,m,t;
srand(time(0));
for (i=0;i<MAXPOP;i++)
for (j=0;j<24;j++)
{a=rand()/(float)RAND_MAX;
if(a<0.5)
oldpop[i][j]=1;
else
oldpop[i][j]=0;
}
for (i=0;i<MAXPOP;i++)
for (j=0;j<24;j++)
{if(oldpop[i][0]==0)
oldpop[i][0]=1;
}
for (i=0;i<MAXPOP;i++)
for (j=0;j<24;j++)
printf("%d %d %d\n",i,j,oldpop[i][j]);
system("pause");
k=0;
for (i=0;i<MAXPOP;i++)
{j=0;
t=0;
while(j<24 && k<6)
{ptk[t][k]=&oldpop[i][j];
k++;
j++;
if(k==6)
{k=0;
t++;}
}
}
for (i=0;i<MAXPOP;i++)
for (j=0;j<6;j++)
printf("%dth %d\n",i,*ptk[i][j]);
system("pause");
return 0;
}
what I am trying to do is to divide the 24 longed oldpop into 4 segments each of which is 6 longed.
thanks for your interest.