Your condition on line 20 will never be true in your case, so number isn't set anywhere and on line 25 you are using uninitializated variable, which leads to undefined behavior.
#include <iostream>
#include <vector>
usingnamespace std;
int main()
{
//int one;
vector<int> vMem;
int temp = 0;
// fill vector with numbers 0 - 4
while(temp < 5){
vMem.push_back(temp);
temp++;
}
// add next number in sequence
int number;
for(int i(0); i < vMem.size(); i++){
if (i != vMem[i]){
number = i; // set number to i
i = vMem.size(); // exit loop
}
}
vMem.push_back(number);
// display numbers
for(int i(0); i < vMem.size(); i++){
cout << vMem[i] << endl;
}
return 0;
}