سؤال

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