fork(3) download
  1.  
  2. #include <stdio.h>
  3.  
  4. // Forward declaration: Here is the name of the structure
  5. // but field-details are omitted.
  6. struct IO_config_t;
  7.  
  8. // typedef of the structure
  9. // Still no details on the fields.
  10. typedef struct IO_config_t IO_config_t;
  11.  
  12. // The parameter is listed.
  13. typedef void (*IO_fun_ptr_t)(IO_config_t* input);
  14.  
  15. // Now we actually detail the members of the structure
  16. struct IO_config_t{
  17. int address;
  18. IO_fun_ptr_t IO_fun_ptr; //pointer to the function to be used
  19. };
  20.  
  21. void print_address (IO_config_t *input){
  22. printf("The address is %d \n", input->address);
  23. printf("Push any key to continue:");
  24. }
  25.  
  26. void main()
  27. {
  28. IO_config_t input = {.address = 16,
  29. .IO_fun_ptr = &print_address};
  30.  
  31. input.IO_fun_ptr(&input);
  32.  
  33. }
Runtime error #stdin #stdout 0s 4572KB
stdin
Standard input is empty
stdout
The address is 16 
Push any key to continue: