0

What's the difference between have a double pointer and have two separet pointers??

I need help :)

7th Jun 2025, 8:11 PM
Olvera De la Huerta Santiago
Olvera De la Huerta Santiago - avatar
3 Antworten
+ 5
for single values, double pointers may seem useless. creating a second pointer to the same value does the same thing. but it's useful for working with array of pointers , array of strings or 2d arrays https://www.geeksforgeeks.org/c-pointer-to-pointer-double-pointer/
7th Jun 2025, 11:42 PM
Bob_Li
Bob_Li - avatar
+ 4
a double pointer points to a pointer After all, pointers themselves need memory space int x = 0; int *ptr1 = &x; // one entity that points to a pointer int **ptr2 = &ptr1; two separate pointers are two different pointer objects/types int x = 0; // seperate entities that dont rely on each other int *ptr1 = &x; int *ptr2 = &x;
7th Jun 2025, 9:24 PM
「HAPPY TO HELP」
「HAPPY TO HELP」 - avatar
0
(1)A double pointer is a pointer that stores the address of another pointer. int x = 10; int *p = &x; int **pp = &p; x is an integer. p points to x. pp points to p — it’s a double pointer. (2)Two Separate Pointers This means you have two independent pointers, each pointing to their own (or maybe the same) data. int a = 5, b = 6; int *p1 = &a; int *p2 = &b; p1 and p2 are not related. Each stores the address of a separate variable.
9th Jun 2025, 4:32 AM
Oloke Peter
Oloke Peter - avatar