Help with this error
Okay so I am making my first c++ program, and I am really new to this so I can't understand why I got this error. Here is 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 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
using namespace std;
int main()
{
double fNumber;
double sNumber;
double _Answer;
string _Method;
cout << "Enter first number: ";
cin >> fNumber >> endl;
cout << "Enter second number: ";
cin >> sNumber >> endl;
cout << "Enter calculation method, (+,-,/,*): ";
cin >> _Method >> endl;
if (_Method == "+")
{
_Answer = fNumber + sNumber;
cout << _Answer << endl;
}
if (_Method == "-")
{
_Answer = fNumber - sNumber;
cout << _Answer << endl;
}
if (_Method == "*")
{
_Answer = fNumber * sNumber;
cout << _Answer << endl;
}
if (_Method == "/")
{
_Answer = fNumber / sNumber;
cout <<_Answer << endl;
}
cout << "That is not a valid method!" <<endl;
system("pause");
}
|
Removing the endl; worked. Thanks
Last edited on
Get rid of the >> endl
That command is only to end line on an output stream, it has no use on an input stream, and will only confuse it.
Topic archived. No new replies allowed.