Skip to main content

All Questions

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
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
2 answers
63 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
-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
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
0 votes
2 answers
96 views

How to deconstruct complex C/C++ statements/declarations?

Take the following snippet as an example. char* const (*(* const bar)[5])(int) Cannot seem to make sense of it or more so, cannot identify the initial point from where to begin making sense of it.
deft artisan's user avatar
1 vote
2 answers
81 views

Why regular swap works with a pointer-to-pointer variable?

I know the difference between these two functions: Swap(int *x, int *y) vs Swap(int **x, int **y). But, I'm not sure how this kind of code works. How is it possible to swap the address which the ...
MatanCode's user avatar
1 vote
1 answer
36 views

what is this casting (long*)x when x is void**

So I found the following code in a program: static void* InterlockedExchangePtr(void** x, void* switchval) { return _InterlockedExchange((long*)(x), (long)(switchval)); } (I know about atomics, ...
Coffee's user avatar
  • 13
0 votes
1 answer
84 views

Why does malloc(0) in C not produce an error when working with char pointer pointers

I'm trying to write a simple split function in c, where you supply a string and a char to split on, and it returns a list of split-strings: #include <stdio.h> #include <stdlib.h> #include &...
Sam van Kesteren's user avatar
0 votes
1 answer
56 views

Getting Null iterate through to next element of array using pointers

#import<stdio.h> #import<stdlib.h> typedef struct Video { char *name; int unique_views; } Video; typedef struct Viewer { char *username; Video *watched_videos; int ...
Anshal Antony's user avatar
0 votes
0 answers
28 views

Pointer to Pointer Memory-address [duplicate]

about pointers in C++ why we use ** in pointer to pointer I just want to know the reason why we use ** in pointer to pointer what is the main reason of using double indirections ?what is the logic ...
Mpujara's user avatar
0 votes
2 answers
530 views

Incompatible pointer type pointer to array and double pointer to array

So i am new to programming and i have this program that i have to write, it has an array of integers and i have to pass it to a function with a pointer and then with a double pointer. After i wrote ...
Cromocon's user avatar

15 30 50 per page
1
2 3 4 5
10