RicardasSim

testing arguments

Feb 2nd, 2023
1,394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.78 KB | None | 0 0
  1. //-Wall -Wextra -Wpedantic -Wshadow
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5.  
  6. typedef struct s_One {
  7.     char c;
  8.     int i;
  9.     float f;
  10. } S_One;
  11.  
  12. typedef struct s_Two {
  13.     double a;
  14.     double b;
  15. } S_Two;
  16.  
  17. typedef struct s_Three {
  18.     S_One s1;
  19.     S_Two s2;
  20. } S_Three;
  21.  
  22. void f1 ( S_One s )
  23. {
  24.     printf("%c  ", s.c );
  25.     printf("%d  ", s.i );
  26.     printf("%f\n", s.f );
  27. }
  28.  
  29. void f3 ( S_Three s )
  30. {
  31.     printf("%c  ", s.s1.c );
  32.     printf("%d  ", s.s1.i );
  33.     printf("%f  ", s.s1.f );
  34.  
  35.     printf("%f  ", s.s2.a );
  36.     printf("%f\n", s.s2.b );
  37. }
  38.  
  39. int main()
  40. {
  41.     f1 ( (S_One){ 'a', 123, 0.1f } );
  42.  
  43.     f3 ( (S_Three) { { 'a', 123, 0.1f }, { 0.21, 0.22 } } );
  44.  
  45.     return 0;
  46. }
  47.  
  48. /*
  49. output:
  50.  
  51. a  123  0.100000
  52. a  123  0.100000  0.210000  0.220000
  53.  
  54. */
  55.  
Advertisement
Add Comment
Please, Sign In to add comment