BW> char *Enlarge(char *p)
BW> {
BW> char *x=new char[20];
BW> delete[] p;
BW> return x;
BW> }
BW> void main()
BW> {
BW> char *sz=new char[10];
BW> sz=Enlarge(sz);
BW> }
BW> so far seems to work, but am I even on the right track?
Sure. But why do you need a separate variable at all?
char *DimChar(char *pszP, int iLen = 19)
{
delete []pszP;
pszP = new char[iLen = 1];
return pszP;
}
Here you have the ability to enlarge your string to any
size with a default value of 19, plus 1 for '\0'.
The lack of a test for NULL on the delete is troublesome,
however. You really should initialize a pointer to NULL
if not initializing it otherwise, and then perform a test
on it before attempting to delete. I'm coming from a C
background though, so perhaps C++ has an exception for this
of which I am not aware and would not be troubled by it.
> ] Let he among you without sin cast the first... OW! HEY!!....
---
---------------
* Origin: *YOPS ]I[* 3.1 GIG * RA/FD/FE RADist * Milwaukee, WI (1:154/750)
|