Question about Pointer.

  • Thread starter Thread starter Khanh01
  • Start date Start date
K

Khanh01

Guest
Hi, could someone please explain help me
why * (testarray + i) doesn't return value but ** (testarray + i) will work, is that a good convention or I misunderstood

int testscore[5]{ 1,2,3,4,5 };
int* testarray[5];
for (int i = 0; i < 5; i++)
{
testarray = &(testscore);
std::cout << (testarray +i) << endl; //-> return address
std::cout << (testarray) << endl; //-> return address

std::cout << *(testarray) << endl; //-> return value
std::cout << *(testarray +i) << endl; //-> return address

}


Thanks a lot :)

Continue reading...
 
Back
Top