Skip to main content
added 262 characters in body
Source Link
Vijay
  • 67.7k
  • 94
  • 238
  • 327

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.

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.

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.

added 1 characters in body
Source Link
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 oneonce the scope is over.

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 one the scope is over.

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.

added 79 characters in body
Source Link
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 second. 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 one the scope is over.

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 second one do not. it stores the array data in stack and not on heap.

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 one the scope is over.

Source Link
Vijay
  • 67.7k
  • 94
  • 238
  • 327
Loading