In the previous example the same happens because when the function is out of scope the array buffer wil be freed, same as when using the delete in the first example.
In the above example there isn't much difference.
Usually new[] is used when you don't know at compile time the size of the array, when you have to return it from a function or when it's too big to fit in the stack
1) You can specify a variable size with new. For instance if the size of the array is determined by user input or something and you don't want to use a fixed number
2) new puts memory on the heap, and without new it goes on the stack. There is much more available memory on the heap, so if you have very very large arrays and you don't use new, you might run out of stack space (will kill the program). Although an array of 10 elements is nothing, so that's not really applicable here.
3) new must be deleted (as per your example)
4) If you don't use new, the array dies as soon as the function is over, whereas if you use new, the array lives for as long as you need it to.
One little question, what is the max of the stack, or is that something you cannot say just like that?
I think it is a good idea to use new when you working with files, such as sending files over a socket.
All right, tnx both its clear to me now.