fork download
  1. #include <stdio.h>
  2. #include <stdint.h>
  3.  
  4. struct s1{
  5. uint8_t u1;
  6. uint32_t u2;
  7. };
  8.  
  9. #pragma pack(1)
  10.  
  11. struct s2{
  12. uint8_t u1;
  13. uint32_t u2;
  14. };
  15.  
  16. int main(){
  17. int s_s1 = sizeof(struct s1);
  18. int s_s2 = sizeof(struct s2);
  19.  
  20. printf("sizeof (s1) = %d\n", s_s1);
  21. printf("sizeof (s2) = %d", s_s2);
  22.  
  23. return 0;
  24. }
Success #stdin #stdout 0s 1788KB
stdin
Standard input is empty
stdout
sizeof (s1) = 8
sizeof (s2) = 5