Link to home
Start Free TrialLog in
Avatar of blossompark
blossomparkFlag for Ireland

asked on

Error C2678: binary '!=': no operator found...

Hello all.

I'm doing some basic work with C++ streams on MS Visual Studio 2015, and I am encountering error C2678 when I attempt to compile this code:

#include <iostream>

using namespace std;

int main()
{
	char ch;
	cout << "enter a phrase: ";
	while ( cin.get(ch) != 0 )
	{
		if (ch == '!')
			cin.putback('$');
		else
			cout << ch;
		while (cin.peek() == '#')
			cin.ignore(1, '#');
	}
	return 0;
}

Open in new window


For line 9, I receive this error output:
C2678      binary '!=': no operator found which takes a left-hand operand of type 'std::basic_istream<char,std::char_traits<char>>' (or there is no acceptable conversion)

Many thanks in advance!
ASKER CERTIFIED SOLUTION
Avatar of phoffric
phoffric

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of blossompark

ASKER

Thank you, it worked like a charm.

And, I'm actually borrowing this account at the moment. The DB questions aren't mine (though I hope to work my way through that subject as well!)

Many thanks.
Avatar of phoffric
phoffric

I think that you can create your own account for free and ask your own questions for free. There is also a premium membership that gives you extra privileges.