문제

I need to convert an 8-bit byte of 1's and 0's to a string reading the same thing. This is what I have

string binstring(byte N) { 
string sN(8,'0');
int temp;
for (int i = 0; i < 8; i++){
temp = (N >> i);
if ((temp%2) == '0') {sN[i] = 0;}
else {sN[i] = 1;}
}
return sN + '0';
}

My problem is the conversion is not happening. Nothing is being outputted.

올바른 솔루션이 없습니다

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top