+ 1

Why only one of the two parts compiles at a time but not both ?

Either Array of 'ptr' compiles or array of 'a' compiles but not both ..why is so ? https://code.sololearn.com/cCsLCKkave5M/?ref=app

16th Jun 2019, 2:22 AM
Krishna Kumar
Krishna Kumar - avatar
7 odpowiedzi
+ 18
Krishna Kumar In your code int *ptr[10] is an array of 10 pointers. Even if we assign address of array a to the ptr then also it will give compilation error because rest of the array of pointers is empty.
16th Jun 2019, 6:35 AM
Night_fury~
Night_fury~ - avatar
+ 2
Again, seems to work fine on my computer. Sololearn does give an error though.
16th Jun 2019, 6:48 AM
Jackson O’Donnell
+ 1
I don't know, it compiles on my computer. It may be something in sololearn's compiler settings.
16th Jun 2019, 4:33 AM
Jackson O’Donnell
+ 1
~ swim ~ Jackson O’Donnell Sorry I had attached a wrong code ...please refer to the corrected code again !
16th Jun 2019, 6:02 AM
Krishna Kumar
Krishna Kumar - avatar
+ 1
Night_fury~ No ,if we convert the last printf statement into comment then the addresses of pointers in the ptr array are displayed irrespective of any intialization to ptr
16th Jun 2019, 6:46 AM
Krishna Kumar
Krishna Kumar - avatar