I wrote the below code for my understanding of pointers.
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
string a = "hello";
const char *st = &a[0];
printf("%p\n", &st[0]);
printf("%p\n", &(a[0]));
printf("%c\n", *st);
printf("%p", &a);
}
This is the output that I get
0x1265028
0x1265028
h
0x7ffe26a91c40
If my understanding is correct &a
should return the address of string, why is the value returned by &a
different than the rest ?