[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 <sslug@sslug> writes:

> hejsa
> 
> 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"
> 
> hvordan gør man lige det?. 

Hvad med at lave et map fra buffer[1] -> streng. Det vil være langt
det hurtigste. Altså

char map[256][9] = {"00000000", "0000001", "0000010", 
....., ....,
 ,"11111111"};

så siger du bare 

char * s = strdup(map[(unsigned int)buffer[i]]);

Eller noget i den dur.

-- 
Christian Hemmingsen


 
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] *