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
0
votes
6 answers
How to evaluate double pointers in c?
I am learning c, and I am quite confused about this double pointer question.
int x = 44;
int *p = &x;
int **t = &p;
bool a = (*t = &x);
I need to tell whether a will be true or false, and the correct answer is true. My thoughts were that t points…

prelude38
- 107
- 7
0
votes
0 answers
Char pointer array and double pointer
How the memory allocation is done for a char pointer array and double pointer.
char *s[]={"knowledge","is","power"};
char **p;
p=s;
cout<<++*p<<*p++<<++*p<

T.g
- 169
- 2
- 11
0
votes
1 answer
C, Dynamic allocation of a matrix: Why is this not allowed?
So I have the following example in some lecture notes
void f(int **p){}
void g(int *p[]){}
void h(int p[2][3]){}
int main(){
int **a;
allocate_mem(a); // allocate memory for a
f(a); // OK!
g(a); // OK!
// h(a); // NOT OK
int…

HereBeeBees
- 145
- 9
0
votes
0 answers
c - Trouble implementing an "add edge" function for a graph
I'm currently working on an assignment to implement Prim's and Dijkstra's algorithms with graphs, but I got hung up trying to implement some basic graph functions based on this header:
//APIs for graph representation by adjacency list
typedef struct…

Mfib
- 3
- 3
0
votes
2 answers
How do I convert a char * string into a pointer to pointer array and assign pointer values to each index?
I have a char * that is a long string and I want to create a pointer to a pointer(or pointer array). The char ** is set with the correct memory allocated and I'm trying to parse each word from the from the original string into a char * and place it…

Jerum
- 71
- 2
- 9
0
votes
0 answers
Chain List, story of pointers
I have this following code:
void pushInList(t_chan **chan, char *name, char *nick_user)
{
t_chan *new_channel;
(void)nick_user;
if ((new_channel = malloc(sizeof(t_chan))) == NULL)
return ;
new_channel->name = name;
…

Oraekia
- 1,167
- 2
- 7
- 14
0
votes
0 answers
error: request for member ‘data’ in ‘* root’, which is of pointer type ‘nodeBST*’
error: request for member ‘data’ in ‘* root’, which is of pointer type ‘nodeBST*’
I just used the pointer to pointer to dereference the data members.Am I following the wrong approach ??
#include
using namespace std;
class nodeBST
{
…

iamworldian
- 39
- 4
0
votes
1 answer
Initialise Pointer to Pointer for struct
i have a console based application in which i am using pointer to a pointer. It is minesweeper game in which i need to create board using pointer to a pointer. I have to pass my this pointer to pointer to a function for initialization purpose. But…

user3768904
- 261
- 3
- 15
0
votes
2 answers
C program, Why dereferece a char pointer to a pointer doesnt get expected value
In this program I have char variable a, b is a pointer to a and c is a pointer to b. While *a=b, *c not equal to b. I don't understand why ,Can anyone explain?
Another thing I don't understand I that if I change variable from char to int,…

J Nguyen
- 113
- 1
- 13
0
votes
1 answer
storing data and printing a double pointer
char** splitInput = malloc(255 * sizeof(char*));
...
while(token != NULL)
{
splitInput[i] = token;
token = strtok(NULL, " ");
i++;
}
I don't know why this code works. In my previous version,
while(token != NULL)
{
*splitInput =…

Hugo
- 129
- 1
- 3
- 14
0
votes
1 answer
Unable to deal with a seems unnecessary pointer to pointer when i was reading the core code of bsd 4.4
I was reading the tcp/ip illustrated v2 and confused with a series of codes on the book.
struct ifnet{
struct ifnet * if_next;
……
}
here is the background information of the structure which may help you learn more about the problem
void…

WaldenShen
- 3
- 1
0
votes
1 answer
How to allocate memory and assign values in a function for an array of pointers?
I am having trouble figuring out how to allocate memory for an array of pointers in a function. In this same function I am trying to initialize the arrays with values from another array. I have been trying different things for a while and I cannot…

J. Donivan
- 15
- 6
0
votes
1 answer
queue structure in C. Accessing pointer in a struct by de-refrencing pointer to that struct
1. struct node {
2. char data;
3. struct node* nxtPtr;
4. }
5.
6. typedef struct node Node;
7.
8. Node* front = NULL;
9. Node* end = NULL;
10.
11. void enqueue(char userData)
12. {
13. Node* temp = malloc(sizeof(Node));
14. …

Philip Butler
- 479
- 1
- 5
- 13
0
votes
4 answers
How do I fit in a comma separated number matrix into a dynamically allocated array in C++?
I have a file that stores a number matrix of unknown shape in format like
-1,4,12,5.7
2.1,3,-10,3.3
7.1,1.11,12,10
I attempt to store the matrix in a dynamically allocated array because I cannot hard code the number of row and column. For this…

Nicholas
- 2,560
- 2
- 31
- 58
0
votes
1 answer
CUDA: pointer to pointer memory access
I can't figure out what is causing the issue. I get "access violation writing location" error in the last line. Am I not correctly allocating the memory?
typedef struct {
doubleXYZW cen_sum; //struct with 4 doubles
double STS[6];
…

Nenu
- 59
- 5