I understand what pointer is but for characters and strings it is quite confused to me. I have I piece of code as below:
#include <iostream>
using namespace std;
int main ()
{
char greeting[6] = {'H', 'e', 'l', 'l', 'o', '\0'};
cout << "Address of 'H' is: "; // line 1
cout << &greeting << endl; // line 2
cout << "Address of 'e' is: "; // line 3
cout << &(greeting[1]) << endl;// line 4
cout << "Address of 'l' is: "; // line 5
cout << &(greeting[2]) << endl;// line 6
return 0;
}
and the output is:
Address of 'H' is: 0x7fff30f13600
Address of 'e' is: ello
Address of 'l' is: llo
Can someone help me to explain why line 4
and line 6
does not produce address?