i am trying to find any user entered value in a array which the user has previously entered the values of. I made the following for finding which values were entered in array bu
Your problem is that an array of integers has no clear definition between assigned and unassigned. You need a way to "flag" these integers. You could do this with a parity array of booleans, that would be flagged based on std::cin.fail(), or use int* and use NULL to flag. There's a lot of ways to do this.
std::vector a(10);
for(int i=0;i<10;i++){
int input;
cout<<"enter value : ";
cin >> input;
if(!cin.fail()) {
a[i] = new int(input);
}else{
cin.clear(std::ios_base::failbit);
}
}
Now you're able to test the vector a for NULL pointers.