| Topic: |
DEVELOP > c-Plus-Plus |
| User: |
"DrBob" |
| Date: |
26 Nov 2003 03:38:02 PM |
| Object: |
Questions about the string class. |
Using gcc 3.3 on MAC OS X.
i have a variable called:
string x;
I need to copy the string using memcpy so how do I get the pointer to
the data and its length in bytes?
.
|
|
| User: "Victor Bazarov" |
|
| Title: Re: Questions about the string class. |
26 Nov 2003 04:09:57 PM |
|
|
"DrBob" <bobrien18@yahoo.com> wrote...
Using gcc 3.3 on MAC OS X.
i have a variable called:
string x;
I need to copy the string using memcpy so how do I get the pointer to
the data and its length in bytes?
Is this a homework assignment?
Take a C++ book and look at the member functions of the
'basic_string' template.
.
|
|
|
|
| User: "=?iso-8859-1?Q?Juli=E1n?= Albo" |
|
| Title: Re: Questions about the string class. |
27 Nov 2003 09:43:32 AM |
|
|
DrBob escribi=F3:
i have a variable called:
string x;
=
I need to copy the string using memcpy so how do I get the pointer to
the data and its length in bytes?
Use the string member function copy.
Regards.
.
|
|
|
|
| User: "Unforgiven" |
|
| Title: Re: Questions about the string class. |
26 Nov 2003 04:08:54 PM |
|
|
DrBob wrote:
Using gcc 3.3 on MAC OS X.
i have a variable called:
string x;
I need to copy the string using memcpy so how do I get the pointer to
the data and its length in bytes?
Getting the string: x.c_str();
Getting the length in bytes: (x.length() + 1) * sizeof(string::value_type)
Remove the +1 bit if you don't need the terminating NULL-character.
--
Unforgiven
"You can't rightfully be a scientist if you mind people thinking
you're a fool."
.
|
|
|
|

|
Related Articles |
|
|