0

Should the memory be freed for the array declaration like below and if so how? I only found delete for dynamic array allocation but no proper description for this kind of array.

char firstname[20];
jason
  • 301
  • 1
  • 3
  • 11
  • For dynamic array allocation, it's `delete[]` not `delete`. But you're better of using `std::vector<>` for dynamic arrays instead, it's got a much easier interface including `.resize`. – MSalters Mar 18 '14 at 00:12
  • This declares an array that is either global or (inside a function) is automatic. In both cases, the runtime asigns memory and frees it appropiately. Just like if it was an, e.g., `int`. – vonbrand Mar 18 '14 at 00:51

1 Answers1

3

No, since it is allocated on stack.

I found this thread useful after typing my answer: C++ Static Array VS Dynamic Array

Community
  • 1
  • 1
taocp
  • 23,276
  • 10
  • 49
  • 62