Re: Cocoa-dev Digest, Vol 2, Issue 1018
Re: Cocoa-dev Digest, Vol 2, Issue 1018
- Subject: Re: Cocoa-dev Digest, Vol 2, Issue 1018
- From: Gen Kiyooka <email@hidden>
- Date: Sat, 2 Jul 2005 08:13:34 -0700
On Jul 2, 2005, at 7:25 AM, Ben Kazez wrote:
On Jul 1, 2005, at 4:12 PM, Frederick C. Lee wrote:
I read that C strings are null terminated whereas C++ strings are
not.
??
try
std::string my_string("with_c_string_initializer");
const char* my_c_string = my_string.c_str();
This doesn't mean that the internal representation is null-
terminated. You're not guaranteed anything about the implementation
of C++ strings, although you are guaranteed some big-O things about
performance. This goes for all the STL classes, I believe (can
someone check me on that?).
std::basic_string::c_str
const charT*
c_str () const;
const charT*
data () const;
Return a pointer to the initial element of an array whose first size
() elements are copies of the elements in this string. A traits::eos
() element is appended to the end. The elements of the array may not
be altered, and the returned pointer is only valid until a non-const
member function of this string is called. If size() is zero, the data
() function returns a NULL pointer.
Ben
--
Ben Kazez
http://www.benkazez.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden