Simple input proble

#include
using namespace std;
int main()
{
int a[10],n=0,l,i,m=0;
while(1)
{
cin>>i;
a[n]=i;
if(a[n]==’\n’||a[n]==’ ')
break;
n++;
}
for(int k=0;k<n;k++)
{
m=m+a[k];
if(m>0)
{
cout<<a[k]<<endl;
}
else
break;
}
}

how to read unknown number of inputs??
what is the problem with this code??

You have to take infinite inputs. You can do that using loops.

Don’t use arrays.

while(1) { // code }