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
-1
votes
1 answer
How to declare a pointer to a class template pointer with different data types in C++
I have a program designed with templates to implement a Huffman tree. My HuffmanNode class has two different data types. Here's the class implementation.
#pragma once
template class HuffmanNode
{
private:
int…

softengstu
- 57
- 1
- 12
-1
votes
3 answers
What is the difference between a , &a and *a?
I am trying to understand the difference between a and &a when a is a pointer.
in the following example code :
int main()
{
int b = 100;
int *a;
a = &b;
printf("%d %d %d", a , &a , *a);
return 0;
}
According to my understanding,…

Severus Tux
- 265
- 3
- 13
-1
votes
2 answers
C: Accessing pointer to pointer to struct element from pointer to structure
I want to access members of a struct from double pointer but I get the error
"error: expected identifier before ‘(’ token"
C Double Pointer to Structure
double pointer to struct inside struct
:
struct test{
struct foo **val;
};
struct foo{
…

user2816078
- 17
- 4
-1
votes
3 answers
C: Array of pointers vs pointer-to-pointer
Do these two pieces of C code achieve the same goal:
char ** p;
p = malloc(sizeof(char*) * 10);
--------------------------------
char * z[10];
It seems like they can be used identically:
p[1] = "Foo";
*(p+2) = "Bar";
---------------------
z[1]…

Victor Brunell
- 5,668
- 10
- 30
- 46
-1
votes
2 answers
How to use double pointer as pointer arrays?
Version 1:
struct mydef_s1 {
int argc;
char *argv[3];
};
struct mydef_s1 *p1 = (struct mydef_s1*) malloc (sizeof (struct mydef_s1));
p1->argv[0] = malloc (8);
p1->argv[1] = malloc (16);
p1->argv[2] = malloc (24);
Now, I…

RRON
- 1,037
- 3
- 12
- 32
-1
votes
2 answers
Reading file into double int pointer
I'm trying to read a file into an array but I'm getting segmentation fault, I know I'm not allocating memory correctly. What am I doing wrong here?. I'm allowed to use read() and while loop.
EDIT
my complete function, before I split in into two…

Junius L
- 15,881
- 6
- 52
- 96
-1
votes
1 answer
Sort pointer to pointer
I'm trying to sort an array of strings that is implemented using a pointer to a pointer. The code I am using is:
void sort(){
char** names;
for(int i = 1; i < size; i++){
int k = i;
while((strcmp(names[k],names[k-1]) < 0) && (k > 0)){
…

tcas271
- 31
- 1
- 5
-1
votes
1 answer
Memory Violation in c++
I'm getting the following error when I run my code:
Unhandled exception at 0x00F66754 in KSU.CIS308.Project5.exe: 0xC0000005: Access violation writing location 0xFDFDFDFD.
I assume it is due to having memory for the pointer but not what it is…

3lliott11
- 3
- 3
-1
votes
3 answers
linked list implementation using pointer to pointer in C
I am unable to append a new node in the linked list. I have already identified the problem area but after much research and trying many things I am still unable to resolve the issue.
The problem is with the for loop in insert_node(char,struct **)…

DarcKnight
- 9
- 4
-1
votes
1 answer
Depth first search & breafth first search implementation in C++
I am a beginning level coder, and am coding dfs bfs, bt its reapetedly showing error,I have assigned an array of nodes for wich i have used pointer to pointer, however when i assign values to elements of each array member, its showing error.THIS IS…

user3505754
- 3
- 4
-2
votes
1 answer
In C can expressions be pointers?
struct node
{
int a;
};
int main()
{
struct node y = {24};
struct node *x = &y;
return 0;
}
I have recently been having trouble to see how the expression &x is a pointer to pointer type (struct **node) but after doing a…

programmerc3981143
- 94
- 1
- 6
-2
votes
2 answers
Pointer Pointer leads to Segmentation Fault in C
Why can I create an array of pointers and dereference its (pointer-)elements.
int a = 1;
int* arr[1];
arr[0] = &a;
But cannot do the same with pointer to pointers:
int** arr2;
arr2[0] = &a;
--> Seg fault

ChiefHan
- 19
- 2
-2
votes
1 answer
Runtime error "load of null pointer of type char" while using char** in C
I am having problems using this pointer to pointers to chars that represents an array of strings.
I should dereference it with some offset i to get the i-th string, then, dereference the result with some other offset j to get the j-th character of…

onlycparra
- 607
- 4
- 22
-2
votes
4 answers
pointer to pointer address
I have a question about pointer to pointer.
Here's my code
#include
void main()
{
int num=10;
int *numPtr1;
int **numPtr2;
numPtr1 = #
numPtr2 = &numPtr1;
printf("%d\n", num);
printf("%d\n", *numPtr1);
…
user5267841
-2
votes
1 answer
Segmentation fault when using strcpy on double pointer
I'm pretty new to C, but have programmed a great deal in both Java and Python. So I got the basics going – however, C keeps hitting me with this Segmentation fault: 11 no matter how I wrap my head around my code. I suspect the problem may be that…

Torstein Norum Bugge
- 56
- 3