fork download
  1. #include <stdio.h>
  2.  
  3. typedef enum {tarasB = 0, superhackkiller1997, other_shit} users_t;
  4.  
  5. char * users[] = {"tarasB", "superhackkiller1997", "other_shit"};
  6.  
  7. typedef void(*say_ptr_t)(char *);
  8.  
  9. users_t global_usr = other_shit;
  10.  
  11. say_ptr_t bind(users_t usr) {
  12. void say(char * str) {
  13. fprintf(stderr, "%s: %s\n", users[global_usr], str);
  14. }
  15. global_usr = usr;
  16. say_ptr_t volatile p = say;
  17. return p;
  18. }
  19.  
  20. int main(void) {
  21. bind(tarasB)("shit");
  22. bind(superhackkiller1997)("i'm god");
  23. bind(other_shit)("ko-ko-ko");
  24. return 0;
  25. }
Success #stdin #stdout #stderr 0s 1828KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
tarasB: shit
superhackkiller1997: i'm god
other_shit: ko-ko-ko