Reputation: 387
void GetarrayElements(int a[]){
int k=0;
while (true){
cout <<"to exit just type a value which is above 100 like ex. 101" << endl;
cout<< "give me the "<< k <<"th element ";
cin >> a[k] >> endl;
if (a[k]<=100 && a[k]>=0){
k+=1;
}
else{
break;
}
}
}
I am trying to read some input values between 0 and 100 inclusive into an array and i got this error. "no match for operator >>". What can be wrong?
Upvotes: 4
Views: 169
Reputation: 81
ostream& endl ( ostream& os );
You cannot pass in a istream instance (std::cin in our case) to endl.
Upvotes: 2
Reputation: 5949
Don't read into the read-only item "endl
".
Change this:
cin >> a[k] >> endl;
...to this:
cin >> a[k];
Upvotes: 5
Reputation: 231103
endl
can only be applied to output streams such as cout
; you cannot use it on cin
.
Upvotes: 11