Advertisement
Guest User

carlita

a guest
Mar 26th, 2020
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.90 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. void    ft_indirection1(int *ptr)
  4. {
  5.     *ptr = 42;
  6. }
  7.  
  8. void    ft_indirection2(int **ptr)
  9. {
  10.     **ptr = 21;
  11. }
  12. int     ft_test1(void)
  13. {
  14.     int i;
  15.  
  16.     i = 0;
  17.     printf("%d <- should be 0\n");
  18.     ft_indirection1(PARAMETER_HERE) // give good parameter here without changing anything
  19.     printf("%d <- should be 42\n");
  20.     return (1);
  21. }
  22.  
  23. /*
  24. int     ft_test2(void)
  25. {
  26.     int i;
  27.     int *bla;
  28.     int **bla2;
  29.  
  30.     i = 0;
  31.     bla = &i;
  32.     bla2 = &bla;
  33.     printf("%d <- should be 0\n");
  34.     ft_indirection1(PARARMETER_HERE) // make it work by using only >>BLA2<< THERE !
  35.     printf("%d <- should be 42\n");
  36.     bla = 0;
  37.     ft_indirection1(PARAMETER_HERE) // make it work by using only >>I<< there
  38.     printf("%d <- should be 42\n");
  39.     bla = 0;
  40.     ft_indirection2(PARAMETER_HERE) // make it work by using only >>BLA<< there
  41.     printf("%d <- should be 42\n");
  42.     return (1);
  43. }
  44. */
  45. int     main(void)
  46. {
  47.     ft_test1();
  48. //  ft_test2();
  49.     return (0);
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement