Pointers are variables themselves, so a pointer that points to another pointer is a pointer to pointer. A pointer to pointer is sometimes mistakenly referred to as "double pointer".
Questions tagged [pointer-to-pointer]
234 questions
0
votes
2 answers
When I try to run it the program crashes and I don't know why
I want to return in my function the n - size of the matrix - and the matrix itself at *p.
The file is something like, for example,
3
10
20
30
this is how I call it:
main( )
{
int n, *p;
n = Load_Matrix( p );
}
int…

kazama
- 211
- 1
- 2
- 10
0
votes
1 answer
Passing and assigning pointer in C
I'm having trouble on how to assign information while using a pointer.
I can't assign any values in the readName function. and can you check if I malloc the structs correctly?
OR
Is there another way to do this without changing the struck and the…

user3335341
- 69
- 5
0
votes
2 answers
Dyanamic 2d array in C++ using double pointer
I have the following code, I made sure I did everything as explained in Pointer-to-pointer dynamic two-dimensional array
I need my 2d matrix to be dyanmic i.e the user needs to enter the dimensions. But I am getting error in my cin when taking the…

Purpamine
- 141
- 2
- 14
0
votes
1 answer
Return the value of pointer using doublepointer
Code:
#include
#include
void createAndFillList(int** ptr,int ninput){
int i;
ptr=malloc(sizeof(int)*ninput);
for(i=0;i

PNC
- 357
- 1
- 5
- 19
0
votes
0 answers
Address of pointer throws a segfault in C++
I have a function that is supposed to return a double pointer, it is supposed to return the address of the pointer to a piece of data which in this example is a character array
The original data is sent as a parameter in the…

Sizdian
- 79
- 1
- 2
- 9
0
votes
1 answer
Double pointer to 2D
I have an an integer array of values and I would like to make a double pointer to point to this array. I assume that this 1D integer array actually represents a 2D array. That is for instance that if I have an int A[2000*12] then I have 12 lines and…

Nick
- 181
- 2
- 11
0
votes
1 answer
Strange C error while freeing memory?
I'm still trying to get my genetic algorithm to work (yesterday I had a problem with memory allocation and consequently an awful error when attempting to free it) but today I have this piece of code
while (iCurrentGen <= data->m_iMaxGenerations)
{
…

Jorge Cespedes
- 547
- 1
- 11
- 21
-1
votes
1 answer
C -- pointers to pointers VERSUS array of pointers
In C, why can't I write:
char **expectedPINs01 = { "0", "5", "7", "8", "9" };
Cause I got:
warning: initialization of ‘char **’ from incompatible pointer type
‘char *’
But it is possible to write:
char *expectedPINs01[] = { "0", "5", "7", "8",…

Adam
- 7
- 4
-1
votes
1 answer
Passing a pointer from one function to another
I am working in C. I have updated the code to include changes made after reviewing comments/suggestions so far.
#include
#include
float * fun2(float Z1, float Z2, float Z3, float K, float (*x)[6]) {
float x0 = *x[0];
float x1 =…

pbhuter
- 373
- 1
- 4
- 17
-1
votes
2 answers
How is this variable of type pointer to pointer
struct node
{
int data;
struct node *link;
};
struct node *addnode(struct node **head);
int main()
{
struct node *head = NULL;
addnode(&head);
return 0;
}
struct node *addnode(struct node **ptrTohead)
{
if (*ptrTohead…

programmerc3981143
- 94
- 1
- 6
-1
votes
1 answer
Linked list program only printing last two nodes of list
I wrote a program to create and print a single linked list. I have used structure pointer to structure pointer for modifying the list. When I print the list it only prints last two nodes added.
#include
#include
struct node{
…
-1
votes
1 answer
Why is a pointer to a structure not overridable in a function?
lets look at this code:
typedef struct nodes{
int val;
struct nodes next;
} node;
insertHead(node *list, int val) {
node *temp = malloc(sizeof(node));
temp->val;
temp->next = list;
list = temp;
}
int main() {
node *list…

moonraccoon
- 83
- 5
-1
votes
1 answer
How to get the size of a double pointer array?
How can I get the size of a dynamically allocated array of double pointers? (pointer to pointer datatype)
int tokencnt=1;
tokenv=(char**)malloc(sizeof(char*));
while(tokencnt<11){
…

Marco Ramirez Castro
- 316
- 2
- 5
- 23
-1
votes
3 answers
Why does a double pointer argument have to be declared as single pointer an passed as &var to the function?
Why does a double pointer argument have to be declared as a single pointer and passed as &var to the function?
I was wondering why I can't just declare a double pointer then pass it to a function, instead I first have to declare the pointer being…
anon
-1
votes
3 answers
Pointers of pointer and pass by reference
I'm struggling to understand how pointers work.
The way I got it is that, when I declare a pointer to, say, int, I create both a variable that'll contain an address (that must be initialized to even operate on the int) and an int variable. Visually,…

thegreatestdoge
- 13
- 1