First one results in undefined behaviourundefined behaviour. For not having UBUB you need to allocate memory using either malloc or calloc. Allocating memory will store the data in heap. After you done with your task , you need to free the allocated memory also.
Second one do not result in UBUB. it stores the array data in stack and not on heap. Memory is automatically freed from stack once the scope is over.