Basically, I have three arrays, CQueue (2D-array), PQueue (2D-array, the same number of arrays as the CQueue, but with each array containing twice as many values) and CC (standard array which is as long as an array in the CQueue). What I want to achieve is taking a specific array in the CQueue, copying it so that CC reads exactly the same as CQueue, and so that the first half of the equivalent array in the PQueue also reads the same.
I've been advised to use memcpy by a friend, which seemed fine but hasn't fixed the problem. I don't know whether the problem lies within me potentially using memcpy incorrectly or whether there's another issue at hand. Following is a simplified version of the relevant part of the code.
int (main)
{
int CQueue[numberOfArrays][halfSize]
int PQueue[numberOfArrays][size]
int CC[halfSize]
for (i = 0; i < numberOfArrays]; i++)
{
memcpy (CC, CQueue[i], halfSize)
memcpy (PQueue[i], CQueue[i], size)
}
}
Any help offered would be much appreciated, thanks!
memcpyis the number of bytes to copy, so you should be copyingX*sizeof(int), not justXCCends up being written over many times and only the last value will remain.