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
-3
votes
2 answers

Segmentation fault when initializing 2D array in c

I am declaring a 2d array in a headers file like this : int **arr; Then I'm allocating memory and I initialize it with zeros. However I'm getting segmentation fault. Here is my code : arr = (int **)malloc(d * sizeof(int *)); for (int u=0; u
-3
votes
1 answer

Freeing linked list crashes when on last node

This is a continuation of a problem I posted yesterday, which I thought was solved, but turns out another problem has been encountered with the way I iterate through the loop and its exit condition. I felt a new question thread might be more…
skevthedev
  • 447
  • 1
  • 7
  • 20
-4
votes
2 answers

Are double-pointer variables useless?

Why should I create a new void** variable when I can simply & to the original variable? Are double-pointer variables useless? Please note I'm not discussing the double-pointer concept. I'm talking about creating a double-pointer variable instead of…
Albert Shown
  • 230
  • 7
-4
votes
2 answers

Local variable values and Address getting retained even after function completes Execution

#include int main() { int var=100; int *ptr=&var; fun(&ptr); printf("%p",ptr); printf("%d\n",*ptr); } int fun(int **var) { int j=10; *var=&j; printf("%p\n",*var); …
Ravi teja
  • 26
  • 4
-4
votes
1 answer

realloc() : Invalid pointer in C

Net is a structure which contain typedef struct net{ int numele; struct net **e; } net; The following code raises the error: realloc(): invalid pointer The realloc is causing problems whenever it is accessed and gives the above error. I…
Prakhar Ganesh
  • 117
  • 2
  • 8
-5
votes
1 answer

Creating Double Pointer

Can I get to know what is happening in the following commands? Here we have H as a structure with n as an integer type structure element. What is var basically after this? float **var; var = new float* [H.n];
A. Rehman
  • 1
  • 2
-5
votes
2 answers

Learning C++ pointer runs into core dump with following code, I really don't why?

#include int main(){ int *array = new int[2]; array[0] = 1; array[1] = 2; int ** dp = NULL; *dp = array; return 0; } when I run it ,Segmentation fault (core dumped). g++ version is Reading specs from…
imotai
  • 2,006
  • 1
  • 12
  • 9
1 2 3
22
23