Questions tagged [pointer-to-pointer]

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".

234 questions
0
votes
2 answers

What does this double pointer do in c programming?

#include #define LENGTH 3 char *words[LENGTH]; int main( int argc, char *argv[] ) { char *pc; // a pointer to a character char **ppc; // a pointer to a pointer character printf( "\n------------Multiple…
ciphermute
  • 401
  • 1
  • 4
  • 4
0
votes
2 answers

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.
0
votes
1 answer

Question about argument in a function as a pointer to a pointer

I am reading the book "C Programming: A Modern Approach" by KN King, where in chapter 17.5 on page 432 they define a function for deleting a node from a singly linked list: The following function, delete_from_list, uses the strategy that we've just…
Fary
  • 77
  • 4
0
votes
1 answer

Failed to manipulate the string passed as pointer to pointer inside the function

I am creating a removeNonAlphaCharacters function trying to remove all non alphabetic characters using C. I could remove all non-alphabetic characters inside the function, but I can not pass the modified string back the original string, which means…
rui wang
  • 3
  • 2
0
votes
1 answer

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 #include #include char ** split(char * tosplit, char delim){ …
0
votes
1 answer

Getting Null iterate through to next element of array using pointers

#import #import typedef struct Video { char *name; int unique_views; } Video; typedef struct Viewer { char *username; Video *watched_videos; int watched_videos_size; } Viewer; int count_views(Viewer…
0
votes
3 answers

How to understand secondary pointer?

i want to ask a question about pointer: void fun(const char** a) {...} 1. const char* b = nullptr; fun(&b); 2. const char** b = nullptr; fun(b); why use 1 but not 2? 1 is good, 2 donnot work
0
votes
1 answer

struct using a pointer, ... in something not a struct or union

I defined a structure called coordonnees declared as a pointer, I want to append values to the pointer a_visiter but it's not working. How can I fix that? Here is the struct code: typedef struct couple { int ligne; int…
Elas
  • 21
  • 2
0
votes
0 answers

Pointer to Pointer Memory-address

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 behind it? or it is just a syntax? are there any…
0
votes
1 answer

how to dynamically allocate a 2d array with the help of a function in C

void alloc_matrix(int ***mat, int *m, int *n) { mat = (int **)malloc(*m * sizeof(int *)); for(int i = 0; i < *m; i++) mat[i] = (int *)malloc(*n * sizeof(int)); for(int i = 0; i < *m; i++) for(int j = 0; j < *n; j++) …
0
votes
1 answer

How to update field of a pointer to a struct in C?

Im trying to update a field of a struct that's a pointer like so: typedef struct Data *STRUCT_POINTER; typedef struct Data { int element; STRUCT_POINTER next; } STRUCT_NODE; void manipulate(STRUCT_POINTER *data ) { data->element =…
Cloyd Abad
  • 617
  • 8
  • 16
0
votes
1 answer

inserting node at the beginning of a circular linked list using void function

I m trying to insert a node at the beginning of a circular linked list using a void function. When i pass pointer to pointer head in the function because i have to change the head itself, it is throwing me some error on line 24 where i marked it…
0
votes
2 answers

G++ responds differently to const int** and const int* as function parameters

I was writing a C++ function that takes int** as input and the function itself does not modify the data (i.e. matrix elements). So I decided to make the argument a const int** type (Is that an acceptable practice?). A sample code is like this: void…
0
votes
2 answers

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 the code i had this error that i couldn't find a…
0
votes
0 answers

Assigning a pointer to "member function pointer" to a pointer to "void"

#include struct Adder { int a, b; int operator()() { // member function. return a+b; } }; int main() { using MemFuncPtr = int(Adder::*)() ; alignas(64) char buf[64]; // closure object (size <= 64) is…