I am trying to initialize this array in C++ :
C++
#include<iostream>
using namespace std;
int main(){
int arr[100];
int i = 10;
while(i){
cin >> arr[--i];
}
return 0;
}
This initializes the array perfectly, but it returns a negative status. How can I solve it?
The status code means the program didn’t get to the last line of your main() function (where it should be return 0), but got killed instead. I guess you just stopped it with CTRL+C.