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];
2
  • 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. Commented Mar 18, 2014 at 0: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. Commented Mar 18, 2014 at 0:51

1 Answer 1

3

No, since it is allocated on stack.

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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.