How to get the value of the first element in two dimensional (2D) array with pointer in C

1 Answer

0 votes
#include <stdio.h>

int main(void)
{
    char arr[3][3] = { {'3','2','1'},
                       {'4','5','6'},
                       {'7','8','9'}};

    char* p = &arr[0][0];

    printf("%c\n", arr[0][0]);
    printf("%c\n", *arr[0]);
    printf("%c\n", **arr);
    printf("%c\n", *p);

    return 0;
}



/*
run:

3
3
3
3

*/

 



answered Feb 21, 2023 by avibootz

Related questions

2 answers 185 views
1 answer 116 views
4 answers 280 views
4 answers 324 views
...