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
2 answers
How to input different values into a 2D pointer-to-pointer array using a for loop C++
I have created two arrays, friends and timechat. Instead of writing long code that manually puts each piece of data into the 2d array I want to do it with a for loop. I have created a 2D array, 2 columns and 5 rows. One column must have all the…

Coder77
- 2,203
- 5
- 20
- 28
0
votes
3 answers
Pointer to arrays syntax
I have a question about syntax of pointer to arrays.
Well we know arrays are pointers themselves(what our uni professor said) so why when we point to them with another pointer (which would be a pointer to pointer) we use this syntax:
int array[10];…

user1288164
- 21
- 6
0
votes
2 answers
crash on trying to reallocate a pointer using pointer to this pointer
I have a pointer to a pointer ("paths") and I want to reallocate each pointer (each "path"). But I get a crash. Generally I am trying to find all possible powers of a number, which one can compute for some amount of operations (e.g for two…

sasha199568
- 1,143
- 1
- 11
- 33
0
votes
3 answers
confused with pointer to pointer concept
Passing a pointer is basically like passing a pointer as value.. the changes to the pointer internally in the function will not modify the actual value of the pointer.. but when we need to access on the actual pointer itself in a function, then we…

CuriousToLearn
- 153
- 1
- 12
0
votes
1 answer
realloc in recursion in trees
I am trying to find the maximum sum leaf to root path in a Binary Tree as in below
http://www.geeksforgeeks.org/find-the-maximum-sum-path-in-a-binary-tree/
1) I am unable to find why the path doesn't get printed in the main()
Is this because of…

sparco
- 85
- 1
- 7
0
votes
2 answers
How to allocate memory for char** in the most efficient way possible when we do not know exact number of words and words' length?
I am curious how to allocate memory for char** when I do not know how many words I will have and what is the maximum length of words.
I need to divide string (which I get as char*) on multiple tokens (words) and save separate words in char**.
I…

YohanRoth
- 3,153
- 4
- 31
- 58
0
votes
5 answers
Is this pointer to pointer redundant?
Code is like this:
void insertNode(TreeNode **root, COMPARE compare, void* data) {
TreeNode *node = (TreeNode *)malloc(sizeof(TreeNode));
node->data = data;
node->left = NULL;
node->right = NULL;
if(*root == NULL) {
…

Dulguun Otgon
- 1,925
- 1
- 19
- 38
0
votes
1 answer
Pointer-to-pointer not working during function call?
I am trying to write a separate file with helper functions for stack operations. I want to pass the stack top by reference as an argument to stack operations from the main file.
Since top is getting modified, I am passing the pointer top by…

puzzledchamp
- 45
- 3
0
votes
1 answer
invalid conversion from 'class**' to 'base class**'
I want to pass a pointer of pointer of object to a function but get the error
invalid conversion from 'CustomInterface**' to LocalLogger**'
I try something like this:
class LocalLogger
{}
class CustomInterface: public…

Psy-Kai
- 187
- 3
- 13
0
votes
1 answer
Error when working with pointer to a pointer in Binary Search Tree functionality
I've got the following code:
#include
#include
#include
#include
using namespace std;
struct Node
{
int value;
Node *left, *right;
Node(int value, Node *l = NULL, Node *r = NULL)
{
…

user1113314
- 803
- 1
- 10
- 24
0
votes
2 answers
PointerToPointer : How to return the modified values/structure back to the original list?
While writing the add function for Linked List I came up with the following piece of code
int addNode(node ** head)
{
1. node * ptr = *head;
if(ptr==NULL)
{
ptr = (node *)malloc(sizeof(node));
…

Dubby
- 1,154
- 3
- 16
- 31
0
votes
2 answers
How to exchange characters in string for enumaration string?
String representing the level in Sokoban:-----#####-----------|-----#@$.#-----------|-----#####-----------
After executing function init_game(LEVEL *level), structure gameshould look like this:
GAME game = {
.x = 6,
.y = 1,
.width = 21,
.height =…

Dounchan
- 319
- 3
- 10
0
votes
0 answers
Void pointer to struct pointers.Prob when putting the address in the void pointer
I got a void **stack which contains the addresses of the struct pointers
my problem is that when I print the whole stack different addresses are shown than the actual addresses I'm actually trying to save in the stack.
I've tested if stud_input…

MattSt
- 1,024
- 2
- 16
- 35
0
votes
2 answers
Compiler error (lvalue required as left operand of assignment) when using malloc
I got 2 structs,a pointer to each struct and a void **stack which points to the pointers of the structs.
my problem is at the line
(*ptr2+*a)=(struct student *)malloc(sizeof(struct student));
*a is a variable that increases by 1 everytime a stud…

MattSt
- 1,024
- 2
- 16
- 35
0
votes
3 answers
What are the ramifications of simply checking a pointers value in a conditional statement?
Here goes my code:
#include
using namespace std;
int countX(char*, char);
int main() {
char msg[] = "there are four a's in this sentence a a";
//char *ptr = msg; // <----- question 2!
cout << countX(msg, 'a');
…

Jhomas Tefferson
- 13
- 4