W
wavelet
If I new one array struct.How can I
easily free the whole array when I don't
need it? Have to delete one by one?Does
it related to compiler? Such as VC vs g++?
eg:
#include <stdio.h>
#include <stdlib.h>
main()
{
struct node
{
int i;
struct node *p;
};
struct node *q,*q1;
q=new struct node[10]; --->How can I free the array later?
q1=q+1;
q->i=1;
(q+1)->i=2;
delete q;
printf("\nq->i=%d",q->i); --->Here is a snap,right?
printf("\nq1->i=%d",q1->i); --->Can here access and get correct value?why
}
easily free the whole array when I don't
need it? Have to delete one by one?Does
it related to compiler? Such as VC vs g++?
eg:
#include <stdio.h>
#include <stdlib.h>
main()
{
struct node
{
int i;
struct node *p;
};
struct node *q,*q1;
q=new struct node[10]; --->How can I free the array later?
q1=q+1;
q->i=1;
(q+1)->i=2;
delete q;
printf("\nq->i=%d",q->i); --->Here is a snap,right?
printf("\nq1->i=%d",q1->i); --->Can here access and get correct value?why
}