+ 1

Are They Same 1(I has an another post too)?

I am confused at this point. When I try to do that: char string1[5][50]; char *const ptr[5]=string1; //My compiler gives an error. I can't remember. But when I look the internet, I saw that they points to a 2d char array with this: char string1 [5][50]; char (*const ptr)[50]=string1. //There is no error. In the first condition,What I thought is that I have a pointer that points to five string and each string has 50 characters. But in the last condition, they points to a array with (look the next post)... ht

7th Dec 2017, 6:22 PM
Yusuf
Yusuf - avatar
1 Odpowiedź
+ 14
This is my limited understanding of the issue. char *const ptr[50]; declares a constant array of size 50 which stores character pointers. char (*const ptr)[50]; declares a constant character pointer which points to a character array of size 50.
7th Dec 2017, 7:16 PM
Hatsy Rei
Hatsy Rei - avatar