Panel użytkownika
Nazwa użytkownika:
Hasło:
Nie masz jeszcze konta?

no match for 'operator>' (operand types are 'std::__cxx11::string' {aka 'std::__cxx11::basic_string<char>'} and 'int')

Ostatnio zmodyfikowano 2020-12-05 19:55
Autor Wiadomość
niewiem123123
Temat założony przez niniejszego użytkownika
no match for 'operator>' (operand types are 'std::__cxx11::string' {aka 'std::__cxx11::basic_string<char>'} and 'int')
» 2020-12-05 19:28:45
Próbuję zrobić kod do konwertowania liczby w systemie czwórkowym na liczbę binarną, lecz w while(str>0) pojawia się problem w tytule.
C/C++
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int main()
{
   
string to_string( int a );
   
int a;
   
cout << "Podaj liczbe w systemie czworkowym: "; cin >> a;
   
stringstream ss;
   
ss << a;
   
string str = ss.str();
   
string b = "";
   
while( str > 0 )
   
{
       
if( str % 2 == 0 ) b = '0' + b;
       
else b = '1' + b;
       
       
str = str / 2;
   
}
   
cout << "Liczba binarna: " << b;
   
return 0;
}
P-177792
pekfos
» 2020-12-05 19:55:05
Nie możesz porównać tekstu z liczbą, ani używać innych operacji arytmetycznych. Użyj typu liczbowego.
P-177793
« 1 »
  Strona 1 z 1