hey guys
i can't figure out what im doing wrong
dear God i miss PHP lol
I am using visual c++ 2010.
I get the following error:Code:#include <iostream> #include <string> using namespace std; int main(){ ////////// practice exercise 4 string word; string letter; int i, numtimes, wordsize; cout << "enter word"; cin >> word; cout << "enter letter"; cin >> letter; wordsize = int(word.size()); for(i = 0; i <= wordsize; ++i){ if(word[i] == letter){ numtimes++; } } cout << numtimes; system("pause"); }
I thought I had to do some kind of type conversion, but the method i used did not help.Code:>c:\users\bakhtawar\documents\visual studio 2010\projects\string manipulation\string manipulation\index.cpp(55): error C2678: binary '==' : no operator found which takes a left-hand operand of type 'char' (or there is no acceptable conversion) 1> c:\program files\microsoft visual studio 10.0\vc\include\exception(470): could be 'bool std::operator ==(const std::_Exception_ptr &,const std::_Exception_ptr &)' 1> c:\program files\microsoft visual studio 10.0\vc\include\exception(475): or 'bool std::operator ==(std::_Null_type,const std::_Exception_ptr &)' 1> c:\program files\microsoft visual studio 10.0\vc\include\exception(481): or 'bool std::operator ==(const std::_Exception_ptr &,std::_Null_type)' 1> c:\program files\microsoft visual studio 10.0\vc\include\system_error(408): or 'bool std::operator ==(const std::error_code &,const std::error_condition &)' 1> c:\program files\microsoft visual studio 10.0\vc\include\system_error(416): or 'bool std::operator ==(const std::error_condition &,const std::error_code &)' 1> while trying to match the argument list '(char, std::string)' ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
any help would be greatly appreciated, thanks
x-ecutioner




Reply With Quote