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
2
votes
1 answer

Accessing uninitialized memory in c

#include int main(){ int i = 3; int *k; k = &i; k++; printf("%d ",*k); return 0; } Output : Garbage value #include int main(){ int i = 3; int *j; int **k; j = &i; k = &j; k++; …
2
votes
1 answer

GDB Dot Operator Dreferencing Pointer?

When debugging with GDB, I noticed something very strange. Namely, the . operator, when used in a print statement, can act just like the -> operator dereferencing a single or even double pointer to get to a field of a struct. Here's a simple…
2
votes
4 answers

Misunderstanding in particular user case of pointers and double-pointers

I'm dealing with pointers, double-pointers and arrays, and I think I'm messing up a bit my mind. I've been reading about it, but my particular user-case is messing me up, and I'd appreciate if someone could clear a bit my mind. This is a small piece…
EUS
  • 422
  • 3
  • 16
2
votes
2 answers

How a double pointer fetch the value from a single poiner

An array is right now pointed by a single pointer. And a double pointer is pointing to the single pointer. I am trying to fetch the value of the array using this double pointer. As far I have only fetched the first index value of the array by the…
user10634362
  • 549
  • 5
  • 21
2
votes
2 answers

Why to cast pointer to double pointer in c?

I am reading OOP in C, and there is this header: #ifndef _NEW_H #define _NEW_H #include #include #include void *new (const void *type, ...); void delete (void *item); typedef struct { size_t size; void…
milanHrabos
  • 2,010
  • 3
  • 11
  • 45
2
votes
1 answer

Why does C program crash when dereferencing pointer to an array?

I have a simple C code: int main() { int test[10] = {1,2,3,4,5,6,7,8,9,10}; int **ptr = &test; printf("%d\n", (*ptr)[0]); return 0; } As soon as it reaches the printf line, it crashes: Process returned -1073741819 (0xC0000005) …
Victor2748
  • 4,149
  • 13
  • 52
  • 89
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 =…
2
votes
3 answers

Overloading subscript operator and working with double-pointers?

I have the following variable that I need to work with, and have to write my own wrapper around it for an assignment. I am going beyond the assignment (since I am going to have to use this wrapper I make) and wanting to overload the subscript…
Smartboy
  • 672
  • 1
  • 8
  • 18
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
  • 385
  • 3
  • 11
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,629
  • 3
  • 18
  • 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
  • 5,293
  • 14
  • 70
  • 122
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…
Matthew Darens
  • 129
  • 2
  • 8
1 2
3
22 23