0

How can I grow the size of a char array?

char myArray[6];

Assumming that all the current elements are occupied how can I add more empty element to the array to input another value into?

7
Contributors
7
Replies
9
Views
4 Years
Discussion Span
Last Post by 9tontruck
2

How can I grow the size of a char array?

That's easy, you can't. Arrays are statically sized and never change. If you want a dynamic array, you'll need to either simulate an array using pointers and dynamic allocation, or switch to a class that does it for you like std::vector.

0

Thanks. But I've been told that I'M not to use classes right now. So I'M pretty much doing C style code in C++. I'll take a look at your link.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.