Questions tagged [pointer-to-pointer]

Pointers are variables themselves, so a pointer that points to another pointer is a pointer to pointer. A pointer to pointer is sometimes mistakenly referred to as "double pointer".

234 questions
-2
votes
2 answers

Assigning values to properties of a 'struct ** record'

I'm having troubles understanding the C double-pointer concept. Essentially, I'm trying to write code which will check if record_1 hasn't been set yet. If not, set it. If it has been set, we'll add a new struct record newRecord to the first records…
kneeki
  • 2,444
  • 4
  • 17
  • 27
-2
votes
1 answer

this pointer pointing to a class property which itself is a pointer

I was wondering why this code fails to compile with an error stating 'Member identifier unexpected in function ....' as 'this' pointer points to the individual object declared in the module itself which makes it like a hidden parameter in this case…
hecate
  • 620
  • 1
  • 8
  • 33
-2
votes
2 answers

Why this pointer to pointer to char is current?

char *array[10]; char **ptr = array; In my opinion, the structure of first sentence is below diagram: But the last sentence, whether this array equal array [0]? And ptr pointer to array[0],array[0] pointer to char? If that's right, How can I…
keen
  • 1
  • 2
-3
votes
2 answers

Confusion about C pointers

I am sending this message to clear my confusion that I could not manage and handle. The foo1 function code should work. I am giving the code details for you. When I run the code, the result is a segmentation error at line 12. Then I made a little…
synapsis
  • 15
  • 2
-3
votes
1 answer

I can't trace this pointer to pointer array program

#include using namespace std; char* str[]={"Man","Woman","Car","Plane",0}; int main(){ char** cp=str; while(*cp!=0) cout<<*cp++<
-3
votes
1 answer

Using an array of pointers-to-pointers to manipulate the pointers it points to (C++)

I've been doing this as an exercise on my own to get better at C++ (messing around with a linked list I wrote). What I want to do is to reverse the list by twisting the pointers around, rather than just 'printing' the data out in reverse (which is…
Zaeche
  • 1
  • 2
-4
votes
2 answers

If I define a pointer pointing to a smart pointer, does this eliminate the advantages of smart pointer?

C++ smart pointer: if in a class, I define a pointer pointing to a smart pointer, does this eliminate the advantages of smart pointer? (Note, I didn't say I want to apply this kind of usage) Like: class TestClass { public SmartPt* ptr1; } Here…
user1914692
  • 3,033
  • 5
  • 36
  • 61
-5
votes
3 answers

Can we get answer 4 with double pointer by these statements in C?

I got a question in c which is int **ptr; printf("%d\n",**ptr); how to print 4 with these statements in c? Here I have two statements and answer should be 4. We can add any statements between two statements but without declaring new variable .…
Saikumar K
  • 35
  • 4
-6
votes
2 answers

What is the meaning of this pointer to pointer statement in C?

int **arr = (int **)malloc(r * sizeof(int *)); how should i interpret the meaning of the above C code ?
user292174
  • 23
  • 3
1 2 3
15
16