S
Sims
Hi,
If i have something like
void foo1()
{
char sz[10];
strcpy( sz, "123456789" );
}
//
// and
//
void foo2()
{
char *sz = new char[10];
strcpy( sz, "123456789" );
delete sz; sz = NULL;
}
In foo2() I allocate memory and de-allocate it later, so i know what is
going on.
But in foo1(), when does it get de-allocated?
Is declaring char sz[10] within a function implying that the compiler will
release the memory on exiting the function?
Is using void foo2() better practice than using void foo1()?
Thanks for your input.
Sims
If i have something like
void foo1()
{
char sz[10];
strcpy( sz, "123456789" );
}
//
// and
//
void foo2()
{
char *sz = new char[10];
strcpy( sz, "123456789" );
delete sz; sz = NULL;
}
In foo2() I allocate memory and de-allocate it later, so i know what is
going on.
But in foo1(), when does it get de-allocated?
Is declaring char sz[10] within a function implying that the compiler will
release the memory on exiting the function?
Is using void foo2() better practice than using void foo1()?
Thanks for your input.
Sims