getbits.c
changeset 132 54a04f5f141d
parent 130 f4b424b93e45
child 140 05d42a3737a4
--- a/getbits.c
+++ b/getbits.c
@@ -4,12 +4,12 @@
  *
  */
 #include <stdio.h>
-#include <limits.h>
+#include <stdlib.h>
 #include <string.h>
 
-#define BITS 64
+#define BITS 8
 
-char *getbits (unsigned long long what)
+char *getbits (unsigned int what)
 {
     static char byte[BITS + 1];
 
@@ -29,16 +29,11 @@
 int main (void)
 {
     unsigned int i;
-    for (i = 1; i < 16; i++)
-        printf ("%s\n", getbits (i));
+    char *s = strdup (getbits (255));
 
-    printf ("%s\n", getbits (USHRT_MAX));
-    printf ("%s\n", getbits (UINT_MAX));
-    printf ("%s\n", getbits (ULONG_MAX));
-
-#ifdef ULLONG_MAX
-    printf ("%s\n", getbits (ULLONG_MAX));
-#endif
+    for (i = 240; i < 255; i++)
+        printf ("%s %s %s %s (%d)\n", s, s, s, getbits (i), i);
+    free (s);
 
     return 0;
 }