Advertisement

08.27.2007 at 10:47AM PDT, ID: 22789607 | Points: 250
[x]
Attachment Details

new char[] question

Asked by grg99 in C++ Programming Language

Tags:

I'm working on an existing program and I see several uses of a curious bit of code:

            gridCharsSeen->Add(new char[ strlen(gridChars) ]);
            strcpy((*gridCharsSeen)[Zero],  gridChars);

----

Now a few questions:

(1)  Isnt this going to break, as the string needs one more byte for the ending zero byte?
(2)  Would it not make more sense to have a method that does this, correctly, in one place,
rather than sixteen separate occurrences of these two lines?

Start Free Trial
[+][-]08.27.2007 at 10:53AM PDT, ID: 19777195

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.27.2007 at 11:25AM PDT, ID: 19777462

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.30.2007 at 02:55AM PDT, ID: 19798652

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628