I am little confused about the use of & literal with strings. I see a big difference in the output of following two codes:
#include <iostream>
using namespace std;
int main()
{
char st[]="This is a Sample String";
cout<<st[0];
return 0;
}
Output: T
#include <iostream>
using namespace std;
int main()
{
char st[]="This is a Sample String";
cout<<&st[0];
return 0;
}
Output: This is a Sample String
I know & is used as a reference operator to pass the value by reference. But my question is how & actually works here.