V
Verbal Kint
Hi.
I would like to know something about the code below. I know, that's not
a nice programming style, because before using the new-Operator a
second time, I should use delete first. But its working fine anyway. So
what is the worst that could happen to my program if I leave it like
that?
CODE:
int main()
{
int i,*val;
val = new int[5];
for (i=0;i<5;i++)
val=i;
val = new int[10];
for (i=0;i<10;i++)
val=i;
delete[] val;
return 0;
}
I would like to know something about the code below. I know, that's not
a nice programming style, because before using the new-Operator a
second time, I should use delete first. But its working fine anyway. So
what is the worst that could happen to my program if I leave it like
that?
CODE:
int main()
{
int i,*val;
val = new int[5];
for (i=0;i<5;i++)
val=i;
val = new int[10];
for (i=0;i<10;i++)
val=i;
delete[] val;
return 0;
}