I'm creating linked list with c++ and I allocated list's memory by using "new" every time.
So I have to use delete to prevent memory leak here, but I'm confused with this because I don't know whether I have to use delete or delete[].
Should I regard the linked list as an array?
struct node {
int data;
node *next;
};
I used the code above to make linked list and just like the code you see, I connected the nodes by using pointer.
So.. do I have to use delete, or delete[] to prevent memory leak?