Well, you could try this way,
Code:
#include <iostream>
#include <vector>
using namespace std;
vector<int> test(10);
int main(int argc, char *argv[])
{
fill(test.begin(), test.begin()+10, 0);
for (int i = 0; i < test.size(); ++i)
{
cout << test[i] << " ";
}
return 0;
}
Also, there's an error here:
Code:
int pass = 4;
int array[pass-1]; // only three indices declared, array[0,2].
for(; j<pass; j++) array[j]=0; // out of bounds check on j = 3 ***
You probably meant;
Code:
int pass = 4;
int array[pass];