Skip to main content

All 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 ...
Frank S.'s user avatar
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; ...
MXF's user avatar
  • 1
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 ...
Artur Karabekov's user avatar
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 ...
user avatar
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; ...
Nenu's user avatar
  • 59
-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[...
RRON's user avatar
  • 1,125
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) ...
user5241471's user avatar
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 ...
user2826534's user avatar