Skip to main content
How are we doing? Please help us improve Stack Overflow. Take our short survey
1 vote
3 answers
135 views

Deleting one node of single linked list use double pointers in C language

I have been reading something related to C language's double pointers, and I have some doubts about the following piece of code. The following piece of code is about the operation of deleting a node ...
user3034702's user avatar
0 votes
3 answers
123 views

Accessing information on a 2d array with a double pointer in a struct (C)

In trying to understand pointers, I created a M[x][y] array, a pointer to said array *p_M[x] and a pointer to said pointer **d_p_M. The first pointer points to the first element of a row in the array ...
pasty guacamole's user avatar
2 votes
3 answers
158 views

Converting to char*** from char* [2][2]

I have the following variable char* a[2][2] = {{"123", "456"}, {"234", "567"}}; I wanted to refer it using another variable. While the cast works, accessing ...
5reep4thy's user avatar
0 votes
0 answers
63 views

Why do we use a single pointer rather than a double pointer to pass an array to a function? [duplicate]

Why not double pointer to take an array? I'm having a bit of problem understanding why an array isn't passed as a double pointer (a pointer to a pointer) since the array name itself is a pointer (...
Hannibal.Br's user avatar
1 vote
4 answers
102 views

char * gives garbage value when pointing to a variable of a function in C

When i pass a pointer to a function and then change the pointer to a another location of the memory, I get SIGSEV or garbage values. Where is a code to demonstrate that: #include <stdio.h> void ...
Mubin Muhammad's user avatar
2 votes
2 answers
115 views

why do I need to add an & sign while allocating a memory space inside a functions? [duplicate]

I wanted to try making an allocate function for a cell in a list, but when using it inside another functions, I need to add an "&" sign I am aware of what "&" means in c (...
nada 's user avatar
  • 33
0 votes
2 answers
79 views

"Magically" avoiding segfault

I wrote a small demo program #include <stdlib.h> #include <stdio.h> typedef struct tag_node { struct tag_node *left, *right, *prev; int value; } node; int main() { node *...
Fyodor's user avatar
  • 195
1 vote
0 answers
76 views

Marshalling double pointers in C#

I have to interact with a provided C library where one of the functions is declared as follows: int GetFileList(struct spiflash_file **ptr_spiflash_filelist, int **file_num); where **...
Marcomattia Mocellin's user avatar
1 vote
2 answers
62 views

Using realloc with pointer to pointer in another function

I'm trying to use realloc in this program to increase an array's size, using pointer to pointer. But it doesn't end up doing the task: #include <stdio.h> void push(int** data) { *data = (...
Javad's user avatar
  • 13
1 vote
1 answer
233 views

Runtime error: `load of null pointer of type 'char'` when indexing an array

I'm trying to write a trim function, but when I try to use it the compiler is giving me a runtime error or load of null pointer of type 'char' when I try to run this code: // Trim trailing whitespace ...
Debuholden's user avatar
2 votes
1 answer
109 views

Necessity of double pointer when using realloc to manipulate array

I am new to C++ programming and want to try out manual memory management (I am aware that it is advised not to use manual memory management, but I still want to give it a try). My goal was to write a ...
Markus's user avatar
  • 23
-3 votes
2 answers
122 views

Confusion about C pointers

I am sending this message to clear my confusion that I could not manage and handle. The foo1 function code should work. I am giving the code details for you. When I run the code, the result is a ...
synapsis's user avatar
0 votes
3 answers
98 views

Addresses in structures

The following is an abstract version of a problem I am currently having. #include <stdio.h> int main() { typedef struct { char * bar } struct_t; struct_t foo = {}; ...
DaRaRa's user avatar
  • 1
0 votes
1 answer
482 views

double pointer to the char array

I have been trying to figure out how double pointer works with char * and char []. What I want to do is to assign a double pointer to the char * or char [] and then change the content. #include <...
Lucky Im's user avatar
1 vote
3 answers
63 views

How does this code allocate memory and why does it fail to write to the allocated memory?

Why does the code below compile successfully but fail to write memory other than address 0? (compiled in dev-cpp 6.3) #include <stdio.h> #include <stdlib.h> void alloc_arr(int **d_ptr); ...
minhaz hosen's user avatar

15 30 50 per page
1
2 3 4 5
17