hello,

i am having an array having 16 values
char index[16]={1,2,3,4,5,6,7,8,9,10,12,13,14,15,16}.

my question is i want to store the first,4th,8th and 12th value in arrar A (ie A[0]=1,A[2]=5,A[3]=9,A[4]=13).
the 2nd,6th,10th and 14th in array B.
the 3rd,7th,11th,15 in array C.
the 4th 8th, 12th 16th in array D


please help.


thanks alot.

Why do you need separate arrays? Just use the index array and a simple expression for figuring out the index.

Using a basic for or while loop, perhaps:

set i and j to zero
while(i is less than 12) {
  a[j]= index[i++]; 
  b[j] = index[i++];
  ... etc.
  j++;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.