All Questions
Tagged with pointer-to-pointer dynamic-memory-allocation
8 questions
1
vote
1
answer
195
views
How to iterate through a dynamic, rectangular matrix in C?
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 ...
0
votes
1
answer
94
views
how to dynamically allocate a 2d array with the help of a function in C [duplicate]
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; ...
0
votes
1
answer
180
views
dynamic array of strings, but i get heap corruption detected
I try to make a dynamic array of char pointer, what means does pointers can be a dynamic memory too, so in the code above I try to allocate one size to the array and in him, allocate to the first ...
2
votes
2
answers
71
views
Dynamic memory addressing and deallocation
I'm trying to solve a problem for a web tutorial (non-marked) where I'm implementing a dynamic array. However, it fails in two places:
Where I try to delete a dynamic array in function ...
0
votes
1
answer
122
views
CUDA: pointer to pointer memory access
I can't figure out what is causing the issue. I get "access violation writing location" error in the last line. Am I not correctly allocating the memory?
typedef struct {
doubleXYZW cen_sum; ...
-1
votes
2
answers
868
views
How to use double pointer as pointer arrays?
Version 1:
struct mydef_s1 {
int argc;
char *argv[3];
};
struct mydef_s1 *p1 = (struct mydef_s1*) malloc (sizeof (struct mydef_s1));
p1->argv[0] = malloc (8);
p1->argv[...
1
vote
2
answers
56
views
What value does a pointer to pointer get assigned when points to a dynamically allocated memory?
Consider the following case:
int **my_array = new int*[10];
What do we assign to my_array here?
my_array is a pointer that points to what?
Is there any way to iterate through my_array (the pointer) ...
23
votes
4
answers
62k
views
Dynamic memory allocation for pointer arrays
I'm am trying to write a program that reads in a series of strings from a text file and stores these in an array of strings, dynamically allocating memory for each element. My plan was to store each ...