Seb
Seb

Reputation: 2016

Countless errors in simple program

The errors go away when I remove the couts/cins:

std::basic_istream<_CharT, Traits>::_istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char, _Traits = std::char_traits, std::basic_istream<_CharT, Traits>::_istream_type = std::basic_istream]

And here's the code:

#include <iostream>
#include <string>
using namespace std;

int main()
{
int x;   
int y;  
int z;   
cout << "Enter number of girrafes" << endl;
cin >> x >> endl;
cout << "Enter number of elephants" << endl;
cin >> y >> endl;
cout << "Enter number of tigers" << endl;
cin >> z >> endl;
}

Upvotes: 0

Views: 82

Answers (3)

mikhail
mikhail

Reputation: 5189

You can't >> endl because endl is an output stream function: endl

Upvotes: 0

Bob Fincheimer
Bob Fincheimer

Reputation: 18066

Remove the endl from the cin statments:

e.g: cin >> x; instead of cin >> x >> endl;

Upvotes: 1

Luchian Grigore
Luchian Grigore

Reputation: 258618

cin >> x >> endl; is illegal, it's basically saying "read into endl".

Just use cin >> x;.

Upvotes: 3

Related Questions