KK> But why do you need a separate variable at all?
KK> char *DimChar(char *pszP, int iLen = 19)
KK> {
KK> delete []pszP;
KK> pszP = new char[iLen + 1];
KK> return pszP;
KK> }
KK> Here you have the ability to enlarge your string to any
KK> size with a default value of 19, plus 1 for '\0'.
Good point, I just used a quick example. My real question was about
whether this would raise any objections, or if there's a better way to
get the job done. I was confused about the way pointers were passed to
a function, and I still am to be honest about it!! :-)
KK> The lack of a test for NULL on the delete is troublesome,
I have never heard of testing the results of delete, I thought it
returned void??? I have been checking new allocations though...
1) set_new_handler(some_exit_func);
which is easiest for me, because it doesn't require checking every
time I use new, it just calls my function and exits with an error
message about insufficient memory if new fails...
2) set_new_handler(0);
tells compiler to make new return a 0 (the old behavior) instead of
throwing an exception. I haven't used exceptions at all, I'm still
trying to learn the basics of c++ but I'm getting there!
L8r,
bw
... 903!brainwave@river.chattanooga.net
--- Blue Wave/DOS v2.20
---------------
* Origin: River Canyon Rd. BBS Chattanooga, Tn (1:362/627)
|