This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/19172] strcpy bug? or mine?
- From: "sebor at roguewave dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 28 Dec 2004 01:32:22 -0000
- Subject: [Bug c++/19172] strcpy bug? or mine?
- References: <20041228000900.19172.rolosworld@gmail.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From sebor at roguewave dot com 2004-12-28 01:32 -------
Subject: Re: strcpy bug? or mine?
rolosworld at gmail dot com wrote:
> ------- Additional Comments From rolosworld at gmail dot com 2004-12-28 01:00 -------
> (In reply to comment #1)
>
>>You forgot C strings are null terminated.
>
>
>
> I did this:
>
> word = new char( strlen(str) + 1 );
Don't you mean new char [strlen(str) + 1]? I.e., brackets, not
parentheses (the latter allocates a single char and initializes
it with the length of str).
Martin
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19172