G
grishin
Good morning,
cplusplus.com says:
"const char* c_str ( ) const;
Get C string equivalent
Generates a null-terminated sequence of characters (c-string) with the
same content as the string object and returns it as a pointer to an
array of characters."
I'm just wondering where does it allocate space and then store the
pointer?
It's a const member so it's not allowed to modify any member then.
"The values in this array are only granted to remain unchanged until
the next call to a non-constant member function of the string object."
For me it says that main string class's storage and c_str's storage
are different storages then.
Some technique I don't know yet.
Thank you.
Yuriy Grishin.
cplusplus.com says:
"const char* c_str ( ) const;
Get C string equivalent
Generates a null-terminated sequence of characters (c-string) with the
same content as the string object and returns it as a pointer to an
array of characters."
I'm just wondering where does it allocate space and then store the
pointer?
It's a const member so it's not allowed to modify any member then.
"The values in this array are only granted to remain unchanged until
the next call to a non-constant member function of the string object."
For me it says that main string class's storage and c_str's storage
are different storages then.
Some technique I don't know yet.
Thank you.
Yuriy Grishin.