Search site Dead Hackers Society
Other BBSes »
 
 

Sillyventure 2017
Demoscene   º   Coding   º   CT60   º   Buy/sell   º   Misc/crap   º   Alive magazine   º   SNDH/Tracking

Misc/crap BBS
 
verpak
Posted by: chemmad Oct,27.2015-14:26 


#include <stdio.h>

/* Druk een int af in bit-representatie */
void druk_bits(int v)
{
int i, masker=1 << 31; /* masker = 100 ... 0 */
for (i=1;i<=32;++i){
putchar(((v & masker)==0)? '0':'1');
v <<= 1;
if (i % 8 ==0 && i !=32)
putchar(' ');
}
}
/* Verpak 4 kararakters in een int */
int verpak(char a, char b, char c, char d)
{
int p=a; /* a, b, c, en d worden in p verpakt */

p=(p << 8)|b;
p=(p<<8)|c;
p=(p<<8)|d;
return p;
}
void pak_uit(int p, char *a,char *b, char *c, char *d)
{
*a=(p & 0xff000000)>>24;
*b=(p & 0xff0000)>>16;
*c=(p & 0xff00)>>8;
*d=(p & 0xff);
}

int main(int argc, char **argv)
{
char a,b,c,d;
int p=100000;
printf("abcd= ");
druk_bits(verpak('a','b','c','d'));
p=verpak('d','i','r','k');
pak_uit(p,&a,&b,&c,&d);
putchar(a);
putchar(b);
putchar(c);
putchar(d);
putchar(' ');
printf("%d",p);
return 0;
}







[All messages in this thread]

Topic Posted by  Date 
verpak chemmad Oct,27.2015-14:26
  Re: verpak chemmad Oct,29.2015-03:08
    Re: verpak dammehc Dec,01.2015-19:35


Reply to this message
Name:
Topic:
Human verification (enter the text of the ASCII-art below):

   _   _   _   _  _  _        _  
 _|_ _|_ _|_ _|_ (_)  ) |_|_ / \ 
  |   |   |   |  (_) /_   |  \_/
Message:




© 1994-2017 Dead Hackers Society Contact: Anders Eriksson