Re: about std::string
- From: Ulrich Eckhardt <eckhardt@xxxxxxxxxxxxxx>
- Date: Fri, 22 Jul 2005 09:53:48 +0200
William wrote:
> {
> std::string str;
> char buff[4096];
> strcpy(buff, "HP Electric Co., Ltd.");
> str = buff;
> } //I get exception here which is "_BLOCK_TYPE_IS_VALID(pHead->nBlockUse)"
Just for your info, that code is ugly but otherwise fine, because "HP..." is
not more than 4096 characters (why such a weird number, btw?).
> 2. if I just copy a string that the size is less than 15, there is no
> exception;
IIRC, that implementation uses a small, internal buffer (perhaps size =
16?). Only if the string doesn't fit there, it allocates memory
dynamically.
> 4. what is the meaning of _Bx._Buf & _Bx._Ptr of std::string?
I'm just guessing, one is the pointer to the allocated memory and the other
is the internal, fixed-size buffer. Expect _Bx to be a union of both.
I think the problem is not in your code but rather the way you compile it,
i.e. the environment.
Uli
.
- Follow-Ups:
- Re: about std::string
- From: William
- Re: about std::string
- From: Stephen Howe
- Re: about std::string
- References:
- about std::string
- From: William
- about std::string
- Prev by Date: about std::string
- Next by Date: Re: about std::string
- Previous by thread: about std::string
- Next by thread: Re: about std::string
- Index(es):
Relevant Pages
|