M
Mike Wahler
Ishira said:Hello all,
I have written a program to test bits in a bit stream. I cant figure
out what is wrong with it.
I have a char * array of 0's and 1's and I basically need to go
through this array and test for ONs and OFFs.
void On_OFF(){
char *pData="11010111";
int offset;
for(int nSample=0,NumSamples=1*8;nSample<NumSamples;nSample++)
{
offset=nSample%8;
if( (pData[nSample/8] & (1u << offset)) == 0)
{
off+=off;
continue;
}
on++;
}
}
#include <stdio.h>
void On_OFF(void)
{
char *pData="11010111";
char *p = pData;
while(*p)
{
printf("pData[%lu] : %s\n", (unsigned long)(p - pData),
*p - '0' ? "ON" : "OFF");
++p;
}
}
int main()
{
On_OFF();
return 0;
}
Output:
pData[0] : ON
pData[1] : ON
pData[2] : OFF
pData[3] : ON
pData[4] : OFF
pData[5] : ON
pData[6] : ON
pData[7] : ON
If you mean something else, please be more clear
with your questions.
-Mike