
-----------------------------------
JR
Sat Jan 26, 2008 11:56 am

finding some digits in an array problem
-----------------------------------
I need to read through an array and take 8 digits out of it if they are either 0 or 1, when i got 8 digits i just convert it into ascii. My problem is that at one point in the array theres only 6 digits so it keeps running to the next bit of digits in the array. how would i add 2 more 0's for example for those 6 digits. might be situations with 5 4 or 3 digits as well so i need to add 0 to the end. 


function - Ignore the case R its for the RPT part.


int bit_to_ascii(const char core[ ], char data[ ])

{
int i,ii,track=0,sum=0,total=128;
int t,num=0;
int asum;
char value;

int a;


    for (i=0,ii=0;core[i] != '\0';i++)
        {
        
         switch(core[i])
         {
          case '0':
          case '1': 
               sum += total * (core[i] - '0');
               total /= 2;
               ii++;
               asum = sum;
               printf("%d\n",sum);
                    
                    if(ii == 8)
                    {
                     if (sum > 31 && sum < 127)
                        {      
                               data[track] = sum;
                               track++;
                               
                               
                        }
                     
                      sum = 0;
                      total = 128;
                      ii = 0;  
                               
                    }           
                 
          case 'R':
                            
               if (core[i+1] == 'P' && core[i+2] =='T')
                  {
                   if (core[i+3] > '0' && core[i+3] = '0' && core[i+4] = '0' && core[i+5] 31 && sum