0

What does it mean when we equals content of a pointer variable to address of 1st element of array?

int value[20]; int * ptr; *ptr==&value[0]; what does the above code mean? don't worry about the function. it's quite different from ptr=&value[0];

6th Mar 2018, 10:06 AM
Purvank Bhiwgade
Purvank Bhiwgade - avatar
1 Antwort
+ 1
The statement *ptr==&value[0]; is an invalid statement, so it really means nothing. You can't compare an integer value (*ptr) to an address/int* in this case (&value[0]). I created some code for you to look at in case it may help you understand. https://code.sololearn.com/cAn4ufOuAkKX if your intention is to point the pointer to the first element of the array, you first need to make sure you're using the assignment operator(=). The following two statements would do this: ptr = value; //an array name is itself a pointer which is why this works ptr = &value[0];
19th Mar 2018, 9:37 PM
Sam
Sam - avatar