-3

I have some old code of mine which i dont understand why i did some thing . I have a pointer which is int_16t *q, of 1024 ints . now i am trying to copy it with :

       buffersRing[ringNum][0]=inNumberFrames;
       memcpy(buffersRing[ringNum]+1, q, inNumberFrames * sizeof *q); 

when first place in array is some int variable, and all other place after that are q.

But, why i havnt done that(and whats the difference ) :

    buffersRing[ringNum][0]=inNumberFrames;
    memcpy(buffersRing[ringNum][1], q, inNumberFrames * sizeof *q); 

Is it trying to put all q ints into the first place in array ? or is it the same?

Curnelious
  • 1
  • 16
  • 76
  • 150
  • Yes the code is valid and works great. it does something very interesting, get the samples from a microphone, and do some dsp on it. by the way , the question is a basic C, to understand the +1 in the array, and what does it means . – Curnelious Sep 19 '13 at 15:14
  • You could use `&buffersRing[ringNum][1]` though. – anishsane Sep 15 '21 at 05:33

1 Answers1

2

No,

buffersRing[ringNum]+1 // refers to a pointer to an array element

is not the same as

buffersRing[ringNum][1] // refers to the actual array element

The first one is the one you want.

Charlie Burns
  • 6,994
  • 20
  • 29