Hi, I'm trying to set bits in clockData{}, which is a byte array. binStr is a string of 1's and 0's that will set the bits. How can I cast the string, binStr, to byte? Thanks in advance for the help.
for (int index = len; index>=0; index-- ) {
strncpy(clockData[pos],(binStr+index),1);
pos++
}
binStr is a string of 1's and 0's that will set the bits. How can I cast the string, binStr, to byte?
binStr is a string of '0' and '1' characters, not a collection of bits.
You need to find a different approach. strncpy is not how you set bits in bytes.
Thanks for the reply. I thought it would be easiest to change clockData[] to a char array, but the error now is, "Invalid conversion from "char" to char*" Can you suggest a better way to do this? Thanks again in advance.
strncpy wants to copy some number of characters from one array to another. clockData is now an array of chars, but but clockData[pos] is not and (binStr+index) is not. (binStr+index) is a character, as is clockData[pos].
I'm still checking, but I don't see a way to do this. I'd rather keep clockData[] as a byte array, but string is ok if necessary. Is there something similar to STR(, MID(, etc., in basic? Thanks again.
I'm still checking, but I don't see a way to do this. I'd rather keep clockData[] as a byte array, but string is ok if necessary. Is there something similar to STR(, MID(, etc., in basic? Thanks again.
Where are you getting binStr from? And what uses ASCII characters to work with bits?