add element to the array?

how to add the element from function to the 1d array in main and need increase to array size too?
Arrays cannot be resized. If you need to do something like that, there two paths you can take:
1. Use an std::vector.
2. Write your own dynamically sized array. This involves allocating a dynamic array -- that is, one created in the heap and not on the stack -- adding data, then copying it to a bigger array when it becomes full.

Unless this is homework and the point of the exercise is figuring out how vectors work, I recommend no. 1.
Topic archived. No new replies allowed.