equal
deleted
inserted
replaced
2 * getbits.c |
2 * getbits.c |
3 * Copyright (C) 2010 Markus Broeker |
3 * Copyright (C) 2010 Markus Broeker |
4 * |
4 * |
5 */ |
5 */ |
6 #include <stdio.h> |
6 #include <stdio.h> |
7 #include <limits.h> |
7 #include <stdlib.h> |
8 #include <string.h> |
8 #include <string.h> |
9 |
9 |
10 #define BITS 64 |
10 #define BITS 8 |
11 |
11 |
12 char *getbits (unsigned long long what) |
12 char *getbits (unsigned int what) |
13 { |
13 { |
14 static char byte[BITS + 1]; |
14 static char byte[BITS + 1]; |
15 |
15 |
16 short i = BITS; |
16 short i = BITS; |
17 |
17 |
27 } |
27 } |
28 |
28 |
29 int main (void) |
29 int main (void) |
30 { |
30 { |
31 unsigned int i; |
31 unsigned int i; |
32 for (i = 1; i < 16; i++) |
32 char *s = strdup (getbits (255)); |
33 printf ("%s\n", getbits (i)); |
|
34 |
33 |
35 printf ("%s\n", getbits (USHRT_MAX)); |
34 for (i = 240; i < 255; i++) |
36 printf ("%s\n", getbits (UINT_MAX)); |
35 printf ("%s %s %s %s (%d)\n", s, s, s, getbits (i), i); |
37 printf ("%s\n", getbits (ULONG_MAX)); |
36 free (s); |
38 |
|
39 #ifdef ULLONG_MAX |
|
40 printf ("%s\n", getbits (ULLONG_MAX)); |
|
41 #endif |
|
42 |
37 |
43 return 0; |
38 return 0; |
44 } |
39 } |