int **p;
p = malloc (x * sizeof *p);

sizeof *p - (i am not quite sure, and i was thinking) does it calculate the size of *p as size of double pointer, size of pointer or as size of variable pointed by pointer

another exmaple with same int **p;

p[n] = malloc (y * sizeof *p[n]);

*p[n] - size of pointer or size of variable pointed by pointer

i think i asked this before somewhere, or wanted to...but didnt want to bother the person who gave me all answers on all other questions, and thread was marked as solved also...

sizeof p gives the size of an int**.
sizeof *p gives the size of an int*.
sizeof **p gives the size of an int.
sizeof *p[n] also gives the size of an int.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.