I have this int **i
or int ***i
or int ****k
how to assign value and to do printf
to/of i
, j
and k
?
also if I have
struct abc { int *i; int **j; int ***k; };
then how to assign and print values to i
, j
, k
if I have
struct abc *b = ...;
struct abc **c = ...;
struct abc ***d = ...;
I assume malloc
will never be needed.
update
I tried like this
int *i=malloc(sizeof(int)*2);
i[0]=5;
int **j=(int **)i;
int ***k=(int ***)j;
printf("%d\n",k[0][0][0]);
but at printf it throws segFault
And also
int *a=malloc(sizeof(int)*3);
int *b=malloc(sizeof(int)*3);
int *c=malloc(sizeof (int) *3);
int **i={a,b,c};
i[0]=a;
i[1]=b;
i[2]=c;
i[0][0]=5;
printf("%d\n",i[0][0]);
again segFault at printf
Update
and how to call scanf and pass i, j and k, and abc like in chqrlie answer ? and if I have a function like
void call_this(struct abc ***d)
{
//how to assign and print
}