All Questions
3 questions
0
votes
2
answers
66
views
2D array of given size
I want to create a 2D array of ints, where the array's dimension is given at run time (not compile time). So far, I have been using:
int **ptr = malloc(m * sizeof(int*));
for (size_t i = 0; i < m;...
1
vote
2
answers
2k
views
declaring char array vs malloc
I was watching the week 5 lecture and David said that a chunk of memory can be allocated two ways:
using malloc();
declaring an array of a certain size (char buffer[10]).
Is there really any ...
0
votes
0
answers
70
views
Initializing a variable in a struct, then in a function
It won't allow me to initialize the array to NULL in the struct in the header file:
typedef struct frog
{
bool is_frog;
struct frog* french_chef[10]; // eg = {NULL};
} frog;
which I get, but ...