Ad
  • Default User Avatar

    Hi, glad to hear you're new to C and trying to understand new concepts. Shortly, this is what we call a dynamic 2D array, in C an array is a pointer (in this case array of ints so it's a pointer on an int).
    Therefore, if you would like to create a 1D array you'll need to create a pointer on the datatype you want (in this case int), and then allocates memory for it.
    But since this is a 2D array you'll need to create a pointer on pointer (which is the double pointer you mentionned) and then for every element of the 2D array you'll need to allocate another array since you want a 2D, because if we can say that a 2D array is a 1D array inside of another one,
    I hope I made some things clear hear, it's a very complex concept since it works with pointers but there you have it (you can also type dynamic 2D array in C on Google if you need clearer idea).

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    ... and determines if the order of the parentheses is valid.

    It is not.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Hello, i was wondering why did you put this string

    tab[i]=(int*)malloc(n*sizeof(int));

    in your first for loop? And why did you declare the tab variable as a double pointer?

    I'm still new to C and i need to understand some concepts about this language

  • Custom User Avatar

    Oh, now i get it. Thank you

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution