Arrays don't work like that. An array has a fixed length throughout its lifetime. There's no possible way to resize an array. Instead, consider the use of std::vector. Also, the length of an array must be known at compile-time and must be a constant integral value - GCC supports non-constant lengths as a left-over from C.