2
I wonder if in the code below (the variable 'p') is a Pointer to an Array of Pointers ?
#include <stdio.h>
int main () {
double valor = 7;
double *balance[5] = {&valor, &valor, &valor, &valor, &valor};
double **p;
p = balance;
return 0;
}
2
I wonder if in the code below (the variable 'p') is a Pointer to an Array of Pointers ?
#include <stdio.h>
int main () {
double valor = 7;
double *balance[5] = {&valor, &valor, &valor, &valor, &valor};
double **p;
p = balance;
return 0;
}
1
The answer to your question is yes, when you did double **p
you have created a variable which is pointer of a pointer of double
. When accessing the value of P
, use *p[índice]
.
#include <stdio.h>
int main (void)
{
double valor = 7.0;
double *balance[5] = {&valor, &valor, &valor, &valor, &valor};
double **p;
p = balance;
int i=0;
for(i=0;i<5;i++)
printf("%lf\n",*p[i]);
return 0;
}
See working on ideone.
Browser other questions tagged c c++
You are not signed in. Login or sign up in order to post.