[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [CPROG] char[1] konvertering til char[8] (enkelt char til bitmønster af char i en char[])



Kim Schulz skrev:
> 
> jeg har en buffer[10] hvor hver byte i den er et bitmønster (f.eks.
> 10101010) og disse vil jeg gerne have over så jeg kan se dem som en
> streng. altså fra buffer[1] til "10101010"

   char buffer[10] = ....
   char out[10][8];

   for(int i=0; i<sizeof(buffer)/sizeof(buffer[0]); i++) {
      for(int x=0; x<8; <++) {
         if( (buffer[i] & (1<<x) = > 0)
            out[i][x] = '1';
         else
            out[i][x] = '0';
      }
   }

Ikke testet !!!
=============

(John =;-)
-- 
Din sikre vej til en sikker backup løsning til dit netværk.
http://www.adilock.dk/~john/
http://www.adilock.dk


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:09 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *