The solution here is to allocate memory to be able to store these numbers. It looks like your tried this on line 14, but that line should look like myArray = newint[size];. Allso, do not forget to call delete[] myArray; when you are finished using this dynamically allocated memory.