Witam, mam problem, otóż nie wiem czemu program wysypuje mi się, gdy chcę wypisać wynik. To mój kod:
#include <iostream>
#include <cstring>
using namespace std;
string liczbahex;
unsigned int ile = sizeof(liczbahex);
void hex2bin(string liczbahex);
int main()
{
cout << "podaj liczbe hex: ";
getline(cin, liczbahex);
cout << "liczba " << liczbahex << " w systemie binarnym to: ";
cout << hex2bin(liczbahex);
return 0;
}
void hex2bin(string liczbahex){
for(unsigned int i = 0; i<ile; i++){
if(liczbahex[i] == '0')
cout << "0000";
else if(liczbahex[i] == '1')
cout << "0001";
else if(liczbahex[i] == '2')
cout << "0010";
else if(liczbahex[i] == '3')
cout << "0011";
else if(liczbahex[i] == '4')
cout << "0100";
else if(liczbahex[i] == '5')
cout << "0101";
else if(liczbahex[i] == '6')
cout << "0110";
else if(liczbahex[i] == '7')
cout << "0111";
else if(liczbahex[i] == '8')
cout << "1000";
else if(liczbahex[i] == '9')
cout << "1001";
else if(liczbahex[i] == 'a')
cout << "1010";
else if(liczbahex[i] == 'b')
cout << "1011";
else if(liczbahex[i] == 'c')
cout << "1100";
else if(liczbahex[i] == 'd')
cout << "1101";
else if(liczbahex[i] == 'e')
cout << "1110";
else if(liczbahex[i] == 'f')
cout << "1111";
}
}
Proszę o pomoc:)