Advertisement
Guest User

Untitled

a guest
Jan 25th, 2015
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. 21:09% cat g.c /tmp/test
  2. #include <stdio.h>
  3.  
  4. int
  5. main(void)
  6. {
  7. const int foo = 3;
  8. char bar[foo];
  9. for (int i = 0; i < foo; i ++) {
  10. bar [i] = 0x30;
  11. }
  12. puts(bar);
  13. return 0;
  14. }
  15.  
  16. 21:09% clang g.c /tmp/test
  17. 21:09% ./a.out /tmp/test
  18. 000
  19. 21:09% gcc g.c /tmp/test
  20. g.c: In function ‘main’:
  21. g.c:8:2: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
  22. for (int i = 0; i < foo; i ++) {
  23. ^
  24. g.c:8:2: note: use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code
  25. 21:10% gcc g.c -std=c11 /tmp/test
  26. 21:10% ./a.out /tmp/test
  27. 000
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement