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.

285 questions
2
votes
2 answers

Double pointers - output explanation

#include int main(void){ int a=1,b=2,c=3; int *p,*q,**r; p=&a; r=&q; q=&c; a=*q+**r; printf("x=%d y=%d z=%d\n",**r,*p,*q); *r=p; a=*q+**r; printf("w=%d\n",a); return 0; } Output: x=3 y=6 z=3 w=12 I…
So Lo
  • 151
  • 6
2
votes
1 answer

Can't assign Static Double Pointer variable

I can't seem to assign a static double pointer variable. Am i doing something wrong? Using .Net 4.7.2 static unsafe float** pointers = (float**)Marshal.AllocHGlobal(sizeof(float) * 32); static unsafe void Main(string[] args) { var i =…
Gabriel Mota
  • 86
  • 1
  • 8
2
votes
1 answer

Passing pointer to a function callback

I want to pass an array to a callback function, but I always get zero (sometimes garbage character) return of call_print(). My code are in two separate files below, and I like to keep it like this. file1.c #include uint8_t dummy[6]…
sas
  • 23
  • 2
2
votes
2 answers

Double pointer addresses

I created and allocated a double pointer like this: int **a; a = (int**)malloc(10 * sizeof(int *)); for (int i = 0; i < 10; i++) *(a+i) = (int *)malloc(10 * sizeof(int)); And then I initialized it for example like this: for (int i = 0;…
Ovidiu Firescu
  • 353
  • 1
  • 9
2
votes
2 answers

Incompatible pointer types (double pointers)

In a function that asks a double pointer like this one: #include void prueba(void **ap) { *ap = NULL; } compiled with the following main: #include #include void prueba(void **ap); int …
2
votes
3 answers

C - Pass and operate on char pointers and pointer-to-pointer

As a novice to the C language I am fighting with pointers, specially with double pointers. My intention is to malloc char pointer in main pass the malloced pointer to different functions get the result of each function within the same pointer free…
Filipe Santos
  • 1,539
  • 3
  • 16
  • 27
2
votes
2 answers

Initialisation from incompatible pointer type warning. Can't find the issue

I'm assuming this warning is crashing my app. I'm using objective-c for an iOS app. Xcode doesn't give a stack trace or anything. Not helpful. I have this assignment as a global variable: int search_positions[4][6][2] =…
Matthew Mitchell
  • 4,747
  • 12
  • 63
  • 114
2
votes
1 answer

Segmentation fault after realloc in function

I have created this code to test one error, that I get in my main code, and it shares the same problem. I'm always getting either segmentation fault or corrupted data (zeros or strange numbers). Here is the code: int *p=NULL; int func (int…
2
votes
3 answers

Best way to allocate memory to a two-dimensional array in C?

What is the best way to allocate memory to a two-d array in C,from both the perspectives : memory-management and speed ? Also, which is better to use, a two-d array (and allocate memory to it) or a double pointer ? Can someone explain in…
Jarvis
  • 8,020
  • 3
  • 23
  • 51
2
votes
2 answers

segmentation fault with uint8_t double pointer

I have a segmentation fault when affecting a value to a[1][0], i thought my mallocs were correct but maybe there're not.. int main() { uint8_t **a; a = malloc(sizeof(uint8_t) * 6); *a = malloc(sizeof(uint8_t) * 2); a[0][0] = 1; //…
aurel_lab
  • 109
  • 8
2
votes
1 answer

Segmentation fault (core dumped) OpenMP

I am trying implement a matrix multiplication with dynamic memory allocation with OpenMP. I manage to get my program to compile fine but when i am trying to execute it i am getting ./ line 14: 17653 Segmentation fault (core dumped)…
mikepapadim
  • 301
  • 1
  • 8
2
votes
3 answers

Typecasting a double pointer in C

I can't figure out this error during parameter passing. #include #include #include typedef char my_char; void myfunc(const my_char** data) { printf ("%s\n", *data); printf ("%s\n", *(data + 1)); } int…
0aslam0
  • 1,357
  • 4
  • 21
  • 39
2
votes
4 answers

Free a double pointer in C

I have two functions to create arrays. double *Array1D (int nx, int dsize) { double *v; v = calloc(nx, dsize); return v; } double **Array2D (int ny, int nx, int dsize) { double **v; int j; for (j = 0; j < ny; j++) v[j] = Array1D(nx,…
user3440489
  • 229
  • 3
  • 10
2
votes
1 answer

Using a "double-pointer" dynamic array in C++

Okay, so I have this assignment that I've gotten stuck on and I'd appriciate any help. Basically what I have is a base-class and two classes that derive from that base class, which hasn't been a problem. But now I need to make a "container" class…
Okee
  • 23
  • 5
2
votes
1 answer

Non-ARC to ARC: Pointer to a pointer to an object (**)

I am trying to convert an iOS project into ARC. I am using the compiler flag for some of the files. But one of the files contains a variable declared within a method like the following: aClass **obj; With ARC turned off, it gives an…
Unheilig
  • 15,690
  • 193
  • 65
  • 96
1 2
3
18 19