Advertisement
dllbridge

Untitled

Jul 26th, 2023
1,179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.05 KB | None | 0 0
  1.  
  2.  
  3. #include   <stdio.h>
  4.  
  5.  
  6.  
  7.  
  8.  
  9. ////////////////////////////////////////////////////
  10. struct Cday
  11. {
  12.    
  13.     int                nYear;
  14.     const char       *pszDay;
  15.     int                 nSec;  
  16. };
  17.  
  18.  
  19. void foo(Cday d);
  20.  
  21.  
  22. ////////////////////////////////////////////////////
  23. int main()                                        //
  24. {
  25.    
  26.     Cday day1;
  27.    
  28.     day1.nYear =      2022;
  29.    
  30.     day1.pszDay = "Monday";
  31.    
  32.     day1.nSec = 1688169600;
  33.    
  34.     printf("size Cday = %d\n", sizeof(day1) );
  35.     printf("address day1 = %d\n", &day1);
  36.     foo(day1);
  37.  
  38. }
  39.  
  40.  
  41.  
  42. ////////////////////////////////////////////////
  43. void foo(Cday d)
  44. {
  45.      printf("address  d   = %d\n", &d);
  46.      
  47.      printf("d.nYear   = %d\n", d.nYear );
  48.      printf("d.pszDay  = %s\n", d.pszDay);
  49.      printf("d.nSec    = %d\n", d.nSec  ); 
  50.      printf(" - - - - - - -\n\n\n\n"    );
  51.      
  52.      
  53.      
  54.      
  55.                   printf("d.nYear   = %d\n",   d );
  56.                  
  57. int *p = (int*)&d;
  58.  
  59.      p = p + 1;   printf("d.pszDay  = %s\n",  *p );      
  60.      p = p + 1;   printf("d.nSec    = %d\n",  *p );
  61. }
  62.  
  63.  
  64.  
  65.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement