How do i pass an array to a pointer ?

In my XAudio code I have my buffer data, im trying to get my buffer data into the fillbuffer function, but it doesn't work. Here's all the relevant code...

int16* bufferData;
bufferData = new int16[buffer.AudioBytes/2];
buffer.pAudioData = (const byte*)bufferData[0];
...
void DebugFillBufferWithSineWave()
{
...
int16* sampleOut = (int16*)&(buffer.pAudioData);

But this and every other variation crash. One variation i got some of the sound to play, but only if i set the sample count to half the actual sample count. Can a C++ person please help.

Edit: I've changed the code a bit, I'm pretty sure the above is just wrong, it now reads ...

buffer.pAudioData = (const byte*)&bufferData[0];
...
int16* sampleOut = (int16*)&bufferData[0];

And one the problems turned out to be the double *sampleOut++, as i was using mono.

Edited by Gavin Williams on
What do you mean with "pass an array to a pointer"? If you are asking how to assing array to pointer, then you do that simply with assignment "=" operator. Arrays also are pointers, so there is nothing to convert:
1
2
3
4
int array[100];
int* pointer = array; // now pointer points to first element of array
pointer = array + 9; // now pointer points to 10th element of array
pointer = &array[9]; // same as line above, but different syntax


If something crashes - examine that in debugger. What line it crashes, what it code is doing on that line (reading memory, writing memory, etc). What are values of variables. And from that information deduce why it is crashing and fix it.