I am interested in how the array looks like to which the pointer stands.
I understand that the function takes the string for example string str = “12345” and turns into an array of charms {‘1’, ‘2’, ‘3’, ‘4’, ‘5’, \ 0} and then returns the pointer On this array
or so {“12345”}?
And another time, if returns the pointer, then why it works:
cout & lt; & lt; str.c_str () & lt; & lt; endl;
Answer 1, Authority 100%
As far as I understand, String :: C_STR
Returns the pointer to the memory area where the row itself stores. That is, when returning does not create any additional arrays, nothing transforms anywhere and does not copy.
about COUT & LT; & lt; str.c_str () & lt; & lt; endl;
: Cout
Excellent displays pointers like CHAR *
or Const Char *
Like lines. You will not embarrass the COUT & LT; & LT; "12345" & lt; & lt; Endl;