fork download
  1. #include <stdio.h>
  2.  
  3. typedef struct {
  4. const int x;
  5. const int y;
  6. } my_struct;
  7.  
  8. enum {
  9. a = 8,
  10. b = 12,
  11. };
  12.  
  13. my_struct test = { a, b };
  14. my_struct test1 = { a+1, b };
  15. my_struct test2 = { a, 'H' };
  16.  
  17. // Also the sizeof operator can produce compile-time constants:
  18.  
  19. my_struct test3 = { sizeof(my_struct), b };
  20.  
  21. int main(void) {
  22. printf("%cello, world!\n", test2.y);
  23. return 0;
  24. }
  25.  
Success #stdin #stdout 0s 10320KB
stdin
Standard input is empty
stdout
Hello, world!