Char to Binary (ASCII to Bin)
Code:
unsigned char *CharToBit (char pValue){
unsigned char *cByte;
unsigned int iCharASCII, iBit = 0;
int iCont;
iCharASCII = pValue;
for (iCont=7; iCont>=0; iCont--){
iBit = iCharASCII % 2;
iCharASCII = iCharASCII / 2;
if (iBit == 1){
cByte [iCont] = '1';
}
else { cByte [iCont] = '0'; }
}
cByte [8] = '\0';
return cByte;
}
..........
cFlag = substr (cStatus, 1,1);
cFuncRes = cFlag [0]; // + '\0';
cFlag = CharToBit (cFuncRes);
This code generate an exception with unknow code.
is There an specific function to convert a Char ASCII to Binary ?