So i was learning about pointers. I tried to experiment myself with pointers so that i could get to know more about it. Here's the code :-
#include<iostream>
using namespace std;
int main() {
char *names[] = {
"james","krushi","kush","assh","kitu","kudi"
};
char **total[4];
total[0] = &names[0];
total[1] = &names[1];
cout<<endl<<"names[0] = "<<names[0]<<endl;
cout<<endl<<"&names[0] = "<<&names[0]<<endl;
cout<<endl<<"names[1] = "<<names[1]<<endl;
cout<<endl<<"&names[1] = "<<&names[1]<<endl;
cout<<endl<<"names[2][0] = "<<names[2][0]<<endl;
cout<<endl<<"&names[2][0] = "<<&names[2][0]<<endl;
return 0;
}
and the output of the last two lines are really unexpected. Like how could it print the whole string instead of the memory address?
Output :-
names[0] = james
&names[0] = 0x7ffc79776e30
names[1] = krushi
&names[1] = 0x7ffc79776e38
names[2][0] = k
&names[2][0] = kush