Sorry i confused i have a int[] not a string. And i want store it as "B1010101" in another int[]. I guess it would be similar. I would take it a look at that function.
How about a complete program that actually compiles, properly indented? That crap that wanders all over the damned place is beyond too hard to read. Is Tools + Auto Format THAT difficult to use?
This may not be what you wanted, but its what you asked for.
// put a character string of zeros and ones into an int array (16 zeros and ones per int).
void convert(char *stringIn, unsigned int *arrayOut) {
int bit = 1;
*arrayOut = 0;
while(*stringIn) {
if(*stringIn++ == '1')
*arrayOut |= bit;
if(!(bit <<= 1)) {
bit = 1;
*++arrayOut = 0;
}
}
}