I'm a total beginner in C++.
I'm not sure if I write the title properly.
I'd like to ask you guys about the line I marked.
#include <iostream>
using namespace std;
int main()
{
char str1[] = "abcd"
char*str2 = str1;
cout << str1 << endl;
cout << str2 << endl; // <- I don't get it.
return 0;
}
In the line I marked, the outcome is "abcd". But I don't understand why it is "abcd".
Cos I thought str2 has str1's memory address. Shouldnt it show the address instead of the value of str1?
Also, when I put cout << *str2 << endl; in that line,
it only shows "a". Why does it show the value of str1[0]? I know the array type's address is array[0]'s address.
thx!