Get address for array element

I am developing a program in C and I have a question about pointers and arrays.

I have the following array pointer :

GLuint *vboIds;

And the following function prototype:

void glGenBuffers(GLsizei n, GLuint *buffers);

The following statement is true:

glGenBuffers(1, vboIds);

But I want to go to the glGenBufferssecond vboIds index as the second parameter to the function. I added the following:

glGenBuffers(1, &&vboIds[1]);

Is it correct?

Thank.

+3
source share
5 answers
glGenBuffers(1, &(vboIds[1]));

or what Armen said

glGenBuffers(1, vboIds + 1);
+5
source

Yes, it would be right if you delete one ampersand.

You can also write glGenBuffers(1, vboIds + 1);.

+3
source
glGenBuffers(1, vboIds + 1);
+1

, , . , :

glGenBuffers(1, &vboIds[1]);

, .

0

(&)

glGenBuffers(1, &vboIds[1]);
0

Source: https://habr.com/ru/post/1777398/


All Articles