All Questions
Tagged with pointer-to-pointer pointers
150 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 ...
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 (...
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 ...
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 *...
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 = (...
-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 ...
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 <...
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);
...
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.
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 ...
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, ...
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 &...
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 ...
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 ...
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 ...