1
If I have a pointer vector of the type *p[tamanho]
, in which each position will be occupied by p[tamanho] = malloc(10*sizeof(int))
, how to access each position of this vector allocated with the malloc
?
1
If I have a pointer vector of the type *p[tamanho]
, in which each position will be occupied by p[tamanho] = malloc(10*sizeof(int))
, how to access each position of this vector allocated with the malloc
?
2
How about this?
int i, j;
for (i = 0; i < tamanho; i++) {
for (j = 0; j < 10; j++) {
printf("%d ", p[i][j]);
}
}
Note that in the first pair of square brackets, we access an array position, which results in a pointer. With the second pair of brackets, we access the array position from the resulting pointer.
Browser other questions tagged c allocation array
You are not signed in. Login or sign up in order to post.