Skip to main content
3 of 4
added 1 characters in body
Vijay
  • 67.7k
  • 94
  • 238
  • 327

First one results in undefined behaviour. For not having UB 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 UB. it stores the array data in stack and not on heap. Memory is automatically freed from stack once the scope is over.

Vijay
  • 67.7k
  • 94
  • 238
  • 327