Questions about the string class.



 DEVELOP > c-Plus-Plus > Questions about the string class.

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
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."
.


  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER