You must overlay &array[i] on void*
for(int i =0; i<10;i++){ std::cout<<(void*)&array[i]<<std::endl; }
This is because C ++ streams work differently for different types. For example, when you pass char* , your data is treated as a C-string, so it prints as a list of characters.
You must explicitly tell C ++ that you want to print the address by casting.
By the way, (void*) not the best way to do this, since you should avoid C-like casting. Always use C ++ style casting ( static_cast , dynamic_cast , reinterpret_cast ). In this case, static_cast will complete the task.
source share