I just want the user to enter some numbers. If the number is -1 the program stops and then outputs those same numbers. Why is that so difficult? I don't understand why the logic is not working here.
For example when the user types:
1 2 3 -1
The program should then print out: 1 2 3 -1
#include <iostream>
using namespace std;
int main()
{
int input, index=0;
int array[200];
do
{
cin >> input;
array[index++]=input;
} while(input>0);
for(int i=0; i < index; i++)
{
cout << array[index] << endl;
}
}