Compiler not liking cin

I have to write a seemingly simple code for class that continues to ask for numbers and add them to a running sum until the user wants to stop. When I try to compile it, I get a very long error message that begins:

lab6-part1.cpp: In function ‘int main()’:
lab6-part1.cpp:11: error: no match for ‘operator>>’ in ‘std::cin. std::basic_istream<_CharT, _Traits>::operator>> [with _CharT = char, _Traits = std::char_traits<char>](((double&)(& number))) >> std::endl’

(This is just the first few lines).

It seems to be having trouble with my cin, and I don't understand why. Here's my code.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Name
// Lab 6, part 1
#include <iostream>
using namespace std;
int main ()
{
    double choice, number, sum=0;
    
    do {
        cout << "How much would you like to add to the sum?";
        cin >> number >> endl;
        
        sum = sum + number;
        
        cout << "Would you like to continue (y/n)? ";
        cin >> choice >> endl;
        
    } while (choice == 'y');
    
    cout << "The total sum is " << sum << endl;
    
    return 0;
}


Thanks for the help!
What exactly do you intend cin >> ... >> endl; to do? Which line are you trying to end with that endl?
Last edited on
To be honest, I don't really know. I was trying things so maybe I could get it to work.
Getting rid of those endl fixed it. Thank you for your help!
Topic archived. No new replies allowed.