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

C++ code breaks when trying to assign a value

I am new to C++ and am trying to write code for a multi-dimensional array using double pointers. This is my code: Class Declaration: class magicMat{ private: int** ptrnum; public: void init(int); void…
SB26
  • 225
  • 1
  • 6
  • 17
-1
votes
1 answer

Passing a custom Matrix class to a Lapack subroutine

I would like the lapack package for some very useful functions which I would not like/being able to implement myself that well. The problem is that I cannot pass my custom Matrix class to the lapack function, I don't get the wanted behaviour. Here…
-1
votes
1 answer

How the double pointer is actually working in reverse of linked list?

I had done the reverse of linked list using recursion, but how the pointer actually working a bit confused. If I swap statements 1 and 2 in the below code the program will not run Why? Because I assume (*head)->next = nullptr will set *temp =…
pawan097
  • 1
  • 2
-1
votes
1 answer

Remove negatives works for some cases, but behaves strange for case 3

Im creating a code in C to remove all the negatives when given a double pointer array with some values, as well as a constant int size. My code behaves strange for the 3rd case, but works for the others. Can someone help point me in the right…
-1
votes
1 answer

How to use double pointers in array

I am in a problem in which I have to write a function which will tokenize the array of characters and then return the array.... I cannnot understand how to use double pointers... The whole code is here: #include using namespace std; char**…
Haider Ali
  • 13
  • 5
-1
votes
3 answers

Declare double pointer from normal variable on single line

How can I declare a double pointer and assign its value directly from a normal variable? int a = 5; int* b = &a; int** c = &b; int** d = &&a;//This does not work int** e = &(&a);//This does not work
sauv0168
  • 93
  • 8
-1
votes
1 answer

Use of triple pointer over double pointer when only reading value of double pointer?

This code only looks like this as the use of structs and global variables is prohibited in the assignment. It works either way, but I was wondering whether only using a double pointer would reallocate a temporary copy of the…
user13079152
-1
votes
1 answer

pointers & pointer to pointer in C

Hey I am trying to understand pointers and I noticed something which causes undefined behavior in my program In first case when I decay pointer to q1 to NULL everything is fine but when I decay pointer *q1 to NULL the terminal does not show anything…
vgag1997
  • 31
  • 1
-1
votes
3 answers

Two different pointer syntax in C which one is right and what's the difference between the two?

I understand the concept of pointers and that we use them in functions to optimize the space we use. What I don't get is the syntax when using them in functions. Example 1: void fun(int * a)//that means we declared a pointer to an integer type a { …
user14565738
-1
votes
1 answer

How can I pass a matrix to a double pointer function?

I have a problem with this program, the program must simply output the minimum value contained in a matrix, this must be done by the function that has as parameter the double pointer (**A) that would be the array , the problem is that after…
Res
  • 13
  • 2
-1
votes
1 answer

Scanf into double pointer

Can you get input in double pointer after scanf? Is this wrong? I have malloced the array in the main function. void input(int **array, int x, int y){ int s,t; printf("array element:\n"); for(s = 0; s < x; s++){ …
James
  • 1
-1
votes
1 answer

Where should I place head for a linked list, inside or outside struct?

Is it best to keep the head (double pointer) of a linked list inside or outside the structure for the linked list itself?
-1
votes
1 answer

How do I fill a string array from a textfile using double pointers?

I'm trying to read a file and save the strings in an array using pointers, but I'm having problems. Can someone give me suggestions of what to do? // not allowed to change these two rows char **Lines; Lines =…
-1
votes
3 answers

why this program crash after i insert the first 2 input

i have to do a dynamic-allocation (double-pointer) in a function and then i have to put in the matrix some number and then deallocate it i have also tried to write **matrice instead of *(matrice[i]) in first function when i have to create a matrix…
ric
  • 69
  • 2
  • 8
-1
votes
2 answers

What am i doing wrong? How can i pass the memory allocated in read function to disp function?

I'm unable to print the matrix that i build using the dynamic memory allocation in read function. Please guide me to pass the values from read to disp function. I've tried passing pointer to pointer in single pointers but i have no idea about double…