Quick question regarding array pointers

Ok, I have a function in which two arrays of unsigned short ints are passed.

1
2
3
4
5
void CheckForMatches(
  unsigned short* arrayB,int sizeB, 
  unsigned short* arrayC,int sizeC) 
{
}


Now to get the value of each element in the arrayB (which works fine, I've verified this using cout) I do the following:

1
2
3
for (int j = 0; j < sizeB; j++)
{
unsigned short int &numB = arrayB[j];


The objective is to set the values of arrayC to the values of arrayB, within the size limits of array C. How to I get the value of numB into arrayC?

I've tried this:

 
arrayC[k] = numB;


Which compiles without complaint. But the resulting array output of arrayC after the function returns does not contain anything resembling what the elements of numB were. I suspect it's a pointer issue, and what arrayC is returning is the memory addresses of numB, I just don't know the syntax to correct it.

Any help, please?
Last edited on
As far as I can tell, arrayC[k] = numB; does what you expect. The problem must be elsewhere. I'd need to see more code.

Can you create a small (minimal) program which reproduces this effect and give the code for it?
Topic archived. No new replies allowed.