Advertisement
Guest User

test.c

a guest
May 21st, 2012
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.83 KB | None | 0 0
  1. /*-
  2.  * Copyright (c) 2012 valsorym <[email protected]>.
  3.  * All rights reserved.
  4.  *
  5.  * Discussion on the forums.freebsd.org.
  6.  *  url: http://forums.freebsd.org/showthread.php?p=177208
  7.  */
  8.  
  9. #include <stdio.h>
  10.  
  11. void hello(char *);
  12. void goodbye(char *);
  13.  
  14. struct my_struct {
  15.     void (*morning)(char *);
  16.     void (*evening)(char *);
  17. };
  18.  
  19. const struct my_struct courtesy = {
  20.   .morning = hello, .evening = goodbye
  21. };
  22.  
  23. int
  24. main(int argc, char **argv)
  25. {
  26.     printf("Somewhere early in the morning.\n");
  27.     courtesy.morning("freethread");
  28.    
  29.     printf("\nAfter a while, on the border of Mexico.\n");
  30.     courtesy.evening("freethread");
  31.    
  32.     return 0;
  33. }
  34.  
  35. void
  36. hello(char *name)
  37. {
  38.     printf("Howdy %s.\n", name);
  39. }
  40.  
  41. void
  42. goodbye(char *name)
  43. {
  44.     printf("Adiós mi amigo %s :)\n", name);
  45. }
  46.  
  47. /* The End. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement