So, I am writing a code to insert (not replace) a new number from the user into an array. I have seen other code on this site and tried to use it but for whatever reason, what I have just replaces it and doesn't keep the number after that.
Also I have other general questions. If an array can take non positive integers, does it still have to be " double arr[] = {} " ? or can it be an int?
This is in my main function (it has other stuff unrelated to the insert function):
1 2 3 4 5 6
|
double arr[size];
cout << "Enter " << size << " numbers" << endl;
for(int i = 0; i < size; i++)
{
cin >> arr[i];
}
|
The output, for example.. if the original array was [1, 2, 3, 4, 6] and I wanted to input '5' between 4 and 6.. it would come out as [1, 2, 3, 4, 5] instead of [1, 2, 3, 4, 5, 6]
All help is appreciated, thank you :)