GeeksforGeeks » C/C++ Programming Questions

Cannot convert 'int[*][9]' to 'int**'. Why?

(2 posts)

Tags:

  1. ganesh
    guest
    Posted 1 year ago #

    void f (int **mat)
    {
    
    }
    
    int main()
    {
      int mat[9][9];
      // f(mat); //Doesn't works.
      f ((int **) mat); //Works.
      return 0;
    } //Why? 
  2. Venki
    Moderator
    Posted 1 year ago #

    The expression 'int[*][9]' is pointer to an array of 9 integers. Which is different from pointer to an integer pointer (int **). See the following example,

    char (*pIntArray)[4]; // Pointer to an array of 4 characters
    char **pCharChar; // Pointer to character pointer.

    If we increment pIntArray by 1, it will be displaced by 4 bytes. Where as, pCharChar will be incremented by only one byte. Hope, makes it clear now.


Reply

You must log in to post.

RSS feed for this topic