| Showdon (39) | |||
So I'm trying to make a program to pull the last 2 numbers off a 5 digit number and output the corresponding color with the number.The program won't run and comes back with this error located at the bottom.
17|error: could not convert `(&std::basic_string<_CharT, _Traits, _Alloc>::substr(typename _Alloc::size_type, typename _Alloc::size_type) const [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>](3u, 2u))->std::basic_string<_CharT, _Traits, _Alloc>::operator= [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>](((const char*)"41"))' to `bool'| C:\Users\Showdon\Desktop\C++\Lab15\Lab1501\main.cpp|21|error: could not convert `(&std::basic_string<_CharT, _Traits, _Alloc>::substr(typename _Alloc::size_type, typename _Alloc::size_type) const [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>](3u, 2u))->std::basic_string<_CharT, _Traits, _Alloc>::operator= [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>](25)' to `bool'| C:\Users\Showdon\Desktop\C++\Lab15\Lab1501\main.cpp|25|error: could not convert `(&std::basic_string<_CharT, _Traits, _Alloc>::substr(typename _Alloc::size_type, typename _Alloc::size_type) const [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>](3u, 2u))->std::basic_string<_CharT, _Traits, _Alloc>::operator= [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>](30)' to `bool'| ||=== Build finished: 3 errors, 0 warnings ===| | |||
|
|
|||
| Peter87 (3687) | |||||
|
Use == for comparison. = is for assignment. You can't compare a string and an integer by using ==. Change the numbers you compare to strings
or change invcode to int and use % to get the two last digits
| |||||
|
|
|||||
| Showdon (39) | |
| Wow duh! Thanks for pointing out the obvious. Totally forgot about the difference of == and =. Thanks | |
|
|
|