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
5 answers

Double pointer in C

Anyone please elaborate what is happining here? int main() { int **p = 0; //p=? and why| *p=? and why|**p=? and why ++p; //p=? and why| *p=? and why|**p=? and why printf("%d\n", p); return 1; } output:- 4 (why?)
Kuntal Basu
  • 830
  • 2
  • 12
  • 28
-2
votes
1 answer

incementing in double pointer

int main() { static int x[]={100,200,300,400,500}; static int *p={x+2,x,x+3,x+4,x+1}; int **ptr=p; ptr++; printf("%d",*ptr); return 0; } can anyone please explain why is the output 500, initially ptr contains x+2, after incrementation, it…
Sagarb
  • 9
  • 4
-2
votes
2 answers

Program crashes when trying to delete last node of a linked list

I am creating a program in which you can and delete a node at any time. However, when I try to delete the last node in the list, the program crashes. Can somebody tell me what I am doing wrong? void delete_node(Node **head_ref) { int position,…
zaro
  • 75
  • 5
-2
votes
1 answer

C++ double pointer assignment

Is there any difference between the following two assignment methods? int * ptr1; int ** ptr2; //method 1 *ptr2 = ptr1; //method 2 ptr2 = &ptr1;
scottc5
  • 41
  • 5
-2
votes
2 answers

Why does a linked list with a double pointer cause an error?

I'm asking you a question because the assignment I was doing didn't work out. The structure is a common link list, declaring the head pointer in the main and passing the address value of the head pointer as a parameter to the function. The global…
Dingchi
  • 7
  • 3
-2
votes
2 answers

Pointer with double pointer

Why cant I assign a pointer to a double pointer's pointer? I get segmentation fault every time. #include int main() { int **pointer1, *pointer2, *pointer3, var; var = 10; pointer3 = &var; pointer1 = &pointer3; …
-2
votes
1 answer

In C, How do you access elements in an array through a double pointer

I am trying to write a program for my class but I can't get started because I don't know how to access the function's argument elements. A char array is passed into the function like this: RPN_calculator(input1) where input1 is a pointer to an…
-2
votes
2 answers

Getting Segmentation fault for double pointer

#include #include #define MAX 256 int main() { char **ptr; char input[MAX]; int i=0,j=0,k=0; printf("Enter the string\n"); scanf("%[^\n]",input); ptr=(char **)malloc(8+1); if(ptr==NULL) { …
Saawaj
  • 41
  • 9
-2
votes
1 answer

Segmentation fault when using strcpy on double pointer

I'm pretty new to C, but have programmed a great deal in both Java and Python. So I got the basics going – however, C keeps hitting me with this Segmentation fault: 11 no matter how I wrap my head around my code. I suspect the problem may be that…
-2
votes
1 answer

Double pointer wont store pointer value correctly and not freeing right

Im using a series of double pointers that point to other double pointers. Currently i have a struct that points to other structs that have double pointers. I was using the "sprintf" command to store values and it was working great until i…
MunajSyed
  • 15
  • 1
  • 6
-2
votes
1 answer

Difficulties about structure and pointers in C

I'm currently facing some problems accessing a double pointer. 1. The double pointer that is an element of a structure. 2. The double pointer is also instance of another structure. 3. That structure also contains an element that is explicitly a…
-2
votes
2 answers

Using double pointers in stuct

Let's say i have a student struct defined: stuct student { struct Student *next; }; typedef struct student Student Now I have the following function: void add_student(Student **student_list_ptr) { Student *new_s; new_s =…
-2
votes
1 answer

Memory allocation for array of structures? 2 examples

I am having the following situation, an array of structs passed to a function. So, inside function I'm dealing with double pointer. Now I am confused, it is working but I'm not sure why is it working on both ways(I like to try things out in…
-2
votes
2 answers

The same variable shared between double pointer and single pointer

Good evening, quick question regarding the following code: // Start of main int i,j; int row,col; printf("Enter the values for row and col:\n"); scanf("%d%d",&row,&col); int **arr=(int**)malloc(row*(sizeof(int*))); for(i=0; i
Shady Programmer
  • 794
  • 4
  • 9
  • 22
-2
votes
1 answer

pointer to pointer to structure with malloc and strdup

My main intention is to pass a pointer to a structure, to a function, which will allocate memory and fill all its values. After returning back i will print it on screen. Structure looks like this. struct isolock{ char *name; unsigned int…
1 2 3
22
23