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".
Questions tagged [pointer-to-pointer]
234 questions
48
votes
14 answers
What does ** do in C language?
I'm new to C with a good background in java and I'm trying to understand pointers and arrays.
I know that subscript operator[] is part of an array definition, so:
int numbers[] = {1,3,4,5};
would create a integer array, which would be represented…

James
- 1,259
- 1
- 10
- 21
22
votes
4 answers
Dynamic memory allocation for pointer arrays
I'm am trying to write a program that reads in a series of strings from a text file and stores these in an array of strings, dynamically allocating memory for each element. My plan was to store each string in an array using a pointer and then grow…

user2826534
- 223
- 1
- 2
- 4
17
votes
4 answers
How to work with pointer to pointer to structure in C?
I want to change member of structure under double pointer. Do you know how?
Example code
typedef struct {
int member;
} Ttype;
void changeMember(Ttype **foo) {
//I don`t know how to do it
//maybe
*foo->member = 1;
}

user43975
- 173
- 1
- 2
- 6
13
votes
1 answer
Why the second argument to pthread_join() is a **, a pointer to a pointer?
I am new to using pthread and also not that familiar with pointers to pointers. Could somebody perhaps explain why the second argument of pthread_join() is a void **. Why is it designed like this.
int pthread_join(pthread_t thread, void…

artic sol
- 349
- 6
- 18
6
votes
2 answers
Multi-dimensional array and pointer to pointers
When you create the multi-dimensional array char a[10][10], according to my book it says you must use a parameter similar to char a[][10] to pass the array to a function.
Why must you specify the length as such? Aren't you just passing a double…

rubixibuc
- 7,111
- 18
- 59
- 98
6
votes
2 answers
malloc and pointers to pointers
I'm trying to understand when I need to use malloc when using multiple levels of pointers. For example,
#include
#include
#include
int main() {
typedef struct {
char first[10];
char last[10];
…

Idr
- 6,000
- 6
- 34
- 49
6
votes
2 answers
Regarding double and triple pointers/double dimension arrays
So, i was playing with C pointers and pointer arithmetic since i'm not entirely comfortable with them. I came up with this code.
char* a[5] = { "Hi", "My", "Name", "Is" , "Dennis"};
char** aPtr = a; // This is acceptable because 'a' is double…

user4709059
- 125
- 1
- 8
6
votes
5 answers
Not able to understand the notations : * and ** with pointers
I have a problem with the pointers. I know what this does:
*name
I understand that this is a pointer.
I've been searching but I do neither understand what this one does nor I've found helpful information
**name
The context is int **name, not…

MLMH
- 141
- 8
6
votes
7 answers
Why should I use double pointer variable to receive another pointer's address(&ptr1)
int num = 45,*ptr1,*ptr2;
ptr1=#
ptr2=&ptr1;
printf("%d\n",*ptr1);
I've been thinking about this question for a while, but couldn't find a way to understand it,why &ptr1 can not be assigned to ptr2 in line 3, &ptr1 is a pointer's address,this…

user2556058
- 311
- 4
- 9
5
votes
4 answers
What happens to a pointer to another pointer when the first one is freed?
I have made a simulation of a stack using malloc to create an array of MAX elements and assign it to a pointer. I then made a second pointer pointing to the first one, to be able to navigate back and forth, executing pushes and pops.
int * stack=…

Georgy90
- 155
- 2
- 12
4
votes
2 answers
Incompatible pointer type warning with pointer-to-pointer types when passing char** to void** function parameter
I'm trying to implement a secure-free function that erases the allocated memory, frees it and then also sets the pointer to the allocated region to NULL so the pointer cannot be reused after-free and cannot be double-freed with the same function. To…

Matjaž
- 292
- 6
- 14
4
votes
3 answers
The function only works with a useless printf
I usually try hard and harder to solve myself any bugs I find in my code, but this one is totally out of any logic for me. It works really fine with whatever strings and char separators, but only with that useless printf inside the while of the…
user9997980
4
votes
3 answers
NSError object already populated on first method call
I am following the book Test-Driven iOS development by G. Lee and came across this unit test, which I don't understand. First of all, if you need more code, please let me know right away.
-(void)testDelegateNotifiedOfErrorWhenNewsBuilderFails
{
…

Houman
- 64,245
- 87
- 278
- 460
4
votes
1 answer
Void pointer pointer (void **)
I am reading a COM sample at http://msdn.microsoft.com/en-us/library/windows/desktop/dd389098(v=vs.85).aspx
I really cannot comprehend (void **) in
hr = pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl);
So I have tried some values…

Hoy Cheung
- 1,552
- 3
- 19
- 36
3
votes
4 answers
Assign a pointer by a pointer to multidimensional array in function
void print_first_n_row(double **matrix, int n, int row_size) {
double (*abc)[row_size];
abc=matrix;}
I am having assignment from incompatible pointer type [-Wincompatible-pointer-types]
abc=matrix error. How can I solve this?

ajdfhjkshg
- 31
- 1