I have a char array of char array like so:
char my_test[2][10];
As you can see I have a length of 2 and then 10. If I need to increase the first char array (2), how can this be done dynamically?
For example, half way through my application char[2] might be in use so therefore I need to use position 3 in the char array. I would then end up with this:
char store[3][10];
But keeping the data originally store in:
char store[0][10];
char store[1][10];
char store[2][10];
mallocandreallocfunctions to create a resizeable array.realloc().210character arrays. A 2D array is an array of arrays. Here, you have and array of 2 - 10-char arrays. Arrays cannot be resized. Blocks of memory can. You can declarechar (*my_test)[10];to create a pointer to an array of 10-chars and then allocate/reallocate the number of 10-char arrays in that block. Or, you can decalrechar **my_test;and allocate and reallocate each individual block each pointer points to.int a = 5;(aholds the immediate value5as its value),int *b;declares a pointer to typeint. Meaning it will hold the address of where an integer is stored as its value. (e.g.b = &a;) would assign the address whereais stored to the pointerb). Nothing else special about them.