Guest User

Untitled

a guest
Apr 19th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.02 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. typedef void (*FUNCTION_INT_INPUT_1_RETURN_VOID)(int);
  5. typedef void (*FUNCTION_INT_INPUT_2_RETURN_VOID)(int, int);
  6.  
  7. void sample_1(int input_a);
  8. void sample_2(int input_y, int input_z);
  9. FUNCTION_INT_INPUT_1_RETURN_VOID main_function (FUNCTION_INT_INPUT_2_RETURN_VOID temp_2);
  10.  
  11.  
  12. // start main function
  13. void main(void) {
  14.  
  15.     printf("trace 3\n\n");
  16.     (main_function(&sample_2))(10);
  17.     printf("trace 4\n\n"); 
  18.  
  19. }
  20.  
  21. void sample_1(int input_a) {
  22.    
  23.     int *temp_a;
  24.     temp_a = (int *)malloc(sizeof(input_a)*1);
  25.     *temp_a = input_a-5;
  26.     printf("result sample_1 is %i\n\n",*temp_a);
  27.     free(temp_a);
  28.    
  29. }
  30.  
  31. void sample_2(int input_y, int input_z) {
  32.  
  33.     int *temp_b;
  34.     temp_b = (int *)malloc(sizeof(input_y)*2); 
  35.     *temp_b = input_y + input_z;
  36.     printf("result sample_2 is %i\n\n",*temp_b);
  37.     free(temp_b);
  38.    
  39. }
  40.  
  41. FUNCTION_INT_INPUT_1_RETURN_VOID main_function (FUNCTION_INT_INPUT_2_RETURN_VOID temp_2) {
  42.  
  43.     if (temp_2) {
  44.  
  45.         temp_2(3,4);
  46.     }
  47.     printf("trace 1\n\n");
  48.     return &sample_1;
  49.    
  50. }
Add Comment
Please, Sign In to add comment