Questions tagged [double-pointer]

The term "double pointer" is sometimes confusingly used to refer a data type which can point to another pointer. This name is confusing because it may mean a pointer to a `double` floating-point object. Please use [pointer-to-pointer] instead.

The term "double pointer" is sometimes confusingly used to refer a data type which can point to another pointer. This name is confusing because it may mean a pointer to a double floating-point object. Please use instead.

337 questions
0
votes
2 answers

What is the cause of pointer alighnment issue?

My program reads words from a file, and stores them in a dynamically allocated array as a number of words. My problem is while in the while loop when I print the array, it seems to pointing to the correct word. After the code falls through the while…
Nilayan
  • 15
  • 2
0
votes
2 answers

Double pointer: pointer to struct member that is a pointer

I'm trying to write a program to play "Pangolin" (like this guy - it asks yes/no questions, walking down a binary tree until it gets to a leaf node. It then "guesses", and if the user says the answer was wrong, asks the user what they were thinking…
Brendan
  • 1,995
  • 1
  • 20
  • 35
0
votes
1 answer

Pointer Dereferencing Problems

I have a function void MOVE_TO(Square **sendingSquare, Square **receivingSquare), where Square is a class: class Square; class Entity { public: Square *currentSq; };// Just a data type--pretend it's your favorite class. class…
iiian
  • 393
  • 1
  • 5
  • 17
0
votes
1 answer

c++ valgrind double pointer delete for memory leak prevention

After reading: C++ Array of pointers: delete or delete []? (reply by shai vashid) and http://www.cplusplus.com/forum/beginner/6651/ I implemented following: Kernel.h unsigned int **ConfigMeM; //..... ~Kernel(){ //destructor for (unsigned int…
algoProg
  • 718
  • 2
  • 11
  • 27
0
votes
1 answer

WIA 2.0 - IWiaDevMgr2::GetImgDlg() - How to declare/init the ppbstrFilePaths parameter

I'm trying to implement some WIA 2.0 code in my VS2012 C++ library and have run into a problem with the IWiaDevMgr2::GetImageDlg call, specifically the ppbstrFilePaths paraneter. I'm not quite sure how to declare/initialize it. From the…
DCreeron
  • 86
  • 2
0
votes
2 answers

Double pointer memory allocation to a struct in C

Can't find what is wrong with this code, it works as expected when inputting exactly 4 values, but on the fifth call (before it even asks for scanf) it always gives me this error: * glibc detected ./a2: double free or corruption (fasttop):…
0
votes
2 answers

Value inside a double pointer isn't updated correctly (C)

I have a function that reads an input file and is supposed to modify the contents of a char** and a int*. The function is as follows: void input_parser(arguments* args, char** input, int* files) { char buffer[MAX]; FILE *fr; fr =…
Bas Jansen
  • 3,273
  • 5
  • 30
  • 66
0
votes
1 answer

Dynamic initialization of array of pointers

class MyClass { int **a; int *b[]; MyClass() { a = new int*[10]; b = new int*[10]; } }; In the above code I get a compilation error at the 2nd line inside the constructor (b = new int*[10]). It says error:…
bibbsey
  • 969
  • 2
  • 9
  • 14
0
votes
1 answer

Double pointer experimenting with 2D array

I am trying to implement a 2D array using a double pointer. How I am trying to implement is visualsing it as per its physical representation. For example, consider a 2 x 2 matrix and its physical representation is c1 c2 R1 -> A00 A01 R2…
user1611753
  • 355
  • 1
  • 4
  • 9
0
votes
2 answers

Free a pointer to a pointer

Let's say a have a function which takes in a buffer for something, and may need to allocate the memory to the buffer in the function's scope. It might look like this: void func_with_buf( ...params..., char** buf ) { if ( !buf ) { buf = (…
zeboidlund
  • 9,731
  • 31
  • 118
  • 180
0
votes
1 answer

Weird Error, error: invalid conversion from ‘const char*’ to ‘char’ [-fpermissive]

Every time I try to compile this (error on line 110) #include std::string anything; int end; char page1[10] [10]; char Pix1; char Pix2; char Pix3; char Pix4; char Pix5; char Pix6; char Pix7; char Pix8; char Pix9; char Pix10; char…
lijrobert
  • 125
  • 2
  • 9
0
votes
3 answers

Filling a Two Dimensional array with random numbers in C++

I am making a program that inserts a two dimensional array with random integers and locates the highest value to display it and it's coordinates in the array. I am using three files. utils.h, utils.cpp, and main.cpp. My program displays an array but…
Kayla Bianchi
  • 67
  • 3
  • 5
  • 11
0
votes
1 answer

C++ LinkedList struct referenced as Double Pointer, and need to access Next Node

Okay, so I have a Linked List struct set up as so: struct ListNode { ListNode* next; int data; ListNode(int in) { data = in; next = NULL; } ListNode(int in, ListNode* n) { data = in; next = n; …
0
votes
4 answers

Accessing the return value using pthread_exit()

I have done the following code. #include #include #include #include struct foo { int a; int b; }; void* thread_func1(void *arg) { struct foo *temp = (struct foo*)malloc(sizeof(struct foo)); …
nitin_cherian
  • 6,405
  • 21
  • 76
  • 127
0
votes
4 answers

simple pointers to pointers

I know why this works: #include void cool_number(int **number) { int value = 42; int *p = &value; *number = p; } int main () { int *number; cool_number(&number); printf("number is %d\n", *number); return 0; } What I don't…
Pablo Fernandez
  • 103,170
  • 56
  • 192
  • 232