fork download
  1. #include <stdarg.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4.  
  5. #define BYTE 256
  6. #define GetBit(array_name, index) \
  7.   (((index) < (array_name)[0]) && ((index) >= 0)) ? \
  8.   (((array_name)[((index) / BYTE) + 1] & ( (unsigned long)1 << \
  9.   ((index) % BYTE))) ? 1 : 0) : \
  10.   (FatalError("Index %ld out of range 0..%ld\n", (long)(index), \
  11.   (long)(array_name)[0]), 0)
  12.  
  13. void FatalError(const char *fmt, ...) {
  14. va_list args;
  15. va_start(args, fmt);
  16. vfprintf(stderr, fmt, args);
  17. va_end(args);
  18. exit(EXIT_FAILURE);
  19. }
  20.  
  21. int main(void) {
  22. int a[] = {1000, 1, 2, 3, 4, 5};
  23. GetBit(a, 2);
  24. return 0;
  25. }
Success #stdin #stdout 0.01s 1716KB
stdin
Standard input is empty
stdout
Standard output is empty