int main()
{
char** subject_array;
char** courses_array;
initialize(subject_array, courses_array);
}
void initialize(char*** subject_array, char*** courses_array)
{
int i;
*subject_array = (char**) malloc(100 * sizeof(char*)); // 100 char pointers
*courses_array = (char**) malloc(100 * sizeof(char*));
for(i = 0; i < 100; i++) //malloc for subject_array
{
(*subject_array)[i] = (char*) malloc(4 * sizeof(char)); // 4 chars for each
(*courses_array)[i] = (char*) malloc(6 * sizeof(char)); // char pointer
}
} //void initialize
My question is: Why is there a discrepancy between the declared double pointers in main and the triple pointers in the initialize function? I think the triple pointer allows me to modify where the 2d array points.
My assignment gives these requirements:
Since you will be changing to where the pointers point, this will involve triple pointers for subjects and courses!
The above code takes care of bolded requirement but I have absolutely no idea what this even means. Can someone break it down to me? Does that mean I can modify contents of the 2d arrays of subject_array and courses_array? Such as swapping? But I can do that already with just double pointers making a 2d array! WHY triple pointers?