Skip to main content
Stack Overflow for Teams is now Stack Internal: See how we’re powering the human intelligence layer of enterprise AI. Read more >
Filter by
Sorted by
Tagged with
Advice
0 votes
3 replies
88 views

I'm in C and I have an int ** (2 dimensional array, it's basically a matrix, it's actually set up a little bit complicated but there's no internal aliasing, so it's not relevant). is this int** ...
Snark's user avatar
  • 1,674
0 votes
3 answers
209 views

I have just encountered a case in this C program: void row_del(int**& a, int& row, int col, int k) { for (int j = 0; j < col; j++) { for (int i = k; i < row - 1; i++) { ...
hacklo's user avatar
  • 17
3 votes
4 answers
143 views

I have a small project (ed-like text editor for myself. Just want to edit some config files using it) and I have some problems with it. workspace_file->flc = malloc(sizeof(char *)); ...
Ho1Ai's user avatar
  • 39
1 vote
3 answers
225 views

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
129 views

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
164 views

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
65 views

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
0 votes
4 answers
119 views

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
132 views

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
84 views

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
  • 185
1 vote
0 answers
82 views

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
71 views

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
256 views

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
126 views

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
128 views

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
102 views

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
586 views

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
65 views

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
67 views

#include <stdio.h> #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 ...
ciphermute's user avatar
0 votes
2 answers
98 views

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
82 views

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
40 views

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
  • 37
1 vote
1 answer
215 views

I have to create a matrix with pointers in dynamic memory in C, fill it with random numbers then print it. This is part of a larger assignment from college (I had to do a whole library of functions ...
Frank S.'s user avatar
0 votes
1 answer
84 views

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 ...
Fary's user avatar
  • 67
1 vote
1 answer
139 views

I have two options. receiving and processing pixel data in a flat array. If I choose it, I have to use single pointer. I have to use this code in every repeated pixel data process. int getIndex(int ...
Ssukdaebat60's user avatar
0 votes
1 answer
55 views

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 ...
rui wang's user avatar
0 votes
1 answer
91 views

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
60 views

#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
3 answers
136 views

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
Yeatsflee's user avatar
0 votes
1 answer
71 views

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 ...
Elas's user avatar
  • 21
0 votes
0 answers
28 views

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
1 answer
100 views

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; ...
MXF's user avatar
  • 1
2 votes
4 answers
934 views

Am doing a task where am supposed to used getline function read input from a user from the terminal. Here is my code: int main(int ac, char **av) { printf("Write something: \n"); ...
user avatar
0 votes
1 answer
73 views

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(...
Cloyd Abad's user avatar
0 votes
1 answer
142 views

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 ...
Neilson Programmer's user avatar
0 votes
2 answers
69 views

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 ...
oaaij-gnahz's user avatar
0 votes
2 answers
555 views

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
1 vote
1 answer
55 views

I am trying to sort three pointers in ascending order of their value y, I'm new using pointers and pointers to pointers so i can´t see the error that is causing a segmentation fault in the execution ...
zpip101's user avatar
  • 17
0 votes
0 answers
142 views

#include <iostream> struct Adder { int a, b; int operator()() { // member function. return a+b; } }; int main() { using MemFuncPtr = int(Adder::*)() ; alignas(64) char buf[64]; ...
tmal's user avatar
  • 97
0 votes
1 answer
113 views

I'm working with c90 on linux. I have a strange bug when I want to end a string, let idx be the index, so when I get to the last index I want the list[idx] to be NULL. example: list[0] actually "...
Ruslan Ver's user avatar
0 votes
1 answer
54 views

In a bigger project i have been working on, i got an Segmentation fault (core dumped), so i managed to reproduce the problem like this: #include <stdio.h> #include <string.h> #include <...
iocode's user avatar
  • 59
0 votes
2 answers
71 views

I was just trying something to understand pointer to pointer deeply. I write the code below int x = 20; int *p0 = &x; int *p1 = &p0; printf("*p0 = %d\n", *p0); printf("**p1 = %d\...
Mohammed Amer's user avatar
1 vote
0 answers
54 views

I am trying to call external functions inside of a DLL from a Jython script using ctypes. The prototype is declared as: extern cl_error_t funcname(const char **varname) That's why I tried to create ...
askar's user avatar
  • 11
0 votes
1 answer
81 views

typedef struct node { int x; struct node *next; struct node **head; } node; Considering this struct, I've implemented a push function: node *push(node *nodo, node *top) { nodo->...
FueledByPizza's user avatar
1 vote
2 answers
80 views

I'm building a program in C to run some simulations for my PhD research. Basically the program uses a function to read an input file with some important values, and then assign these values to ...
Luguecos's user avatar
  • 341
0 votes
1 answer
55 views

I am searching a string in a BST. If I found the string, I just return it. If not found, I print 3 suggestions: the last traversed node before declaring that the node is not found the inorder ...
Anas Mostafa's user avatar
0 votes
1 answer
713 views

I am trying to load words from a text file into a binary search tree. Each line of the file contains one word. #include <stdio.h> #include <stdlib.h> #include <string.h> typedef ...
Anas Mostafa's user avatar
-1 votes
1 answer
61 views

In C, why can't I write: char **expectedPINs01 = { "0", "5", "7", "8", "9" }; Cause I got: warning: initialization of ‘char **’ from incompatible ...
Adam's user avatar
  • 25
0 votes
0 answers
53 views

I recently wrote a MyStack class which would work just like STL stack. Now i decided to write MyStack struct, which I will work with using functions instead of methods struct Stack { int _data; ...
Miroigrin's user avatar
0 votes
1 answer
2k views

I'm trying to create a program to print a 2D matrix after reading in data from a file. My program works fine if the 2D matrix is a square with equal X & Y values, but I get the "corrupted ...
Blunderbuss's user avatar

1
2 3 4 5