fork(4) download
  1. #include <stdio.h>
  2.  
  3. #define foreach(item, array) \
  4.   for(int keep = 1, \
  5.   count = 0,\
  6.   size = sizeof (array) / sizeof *(array); \
  7.   keep && count != size; \
  8.   keep = !keep, count++) \
  9.   for(item = (array) + count; keep; keep = !keep)
  10.  
  11. int main(void)
  12. {
  13. int values[] = { 1, 2, 3 };
  14.  
  15. foreach(int *v, values)
  16. printf("value: %d\n", *v);
  17.  
  18. return 0;
  19. }
Success #stdin #stdout 0s 2160KB
stdin
Standard input is empty
stdout
value: 1
value: 2
value: 3