This is probably something that can be easily solved. I have no idea what I am doing wrong, please help with this super simple code.
#include <iostream>
using namespace std;
int main()
{
int arraysize, i, a[arraysize], n, j;
cout << "array size";
cin >> arraysize;
for(int i=0, j = arraysize; i < arraysize, j > 0; i++, j--){
a[i] = j;
cout << "a[" << i << "] = " << a[i] << endl;
}
}
When executing this program, it will output 5 values of the array, and then I get a segmentation fault. I have no idea how to fix this and\or how to properly execute this type of problem. Any help is appreciated, thank you.