Vulpes

structs1

Nov 9th, 2011
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.64 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3.  
  4.  
  5.  
  6. //char         1 byte
  7. //int          4 bytes
  8. //float        4 bytes
  9. //double       8 bytes
  10. //short int    2 bytes
  11. //long int     8 bytes
  12.  
  13.  
  14. struct mystruct {
  15.     char y;      // 1 byte
  16.     int x;       // 4 bytes
  17.     int z;       // 4 bytes
  18.     short int w; // 2 bytes
  19. }; // 11 bytes big
  20.  
  21. typedef struct mystruct mystruct_t; // I want to call "struct mystruct" as "mystruct_t" instead
  22.  
  23.  
  24. int main () {
  25.  
  26.     int a;
  27.    
  28.     struct mystruct my_object1;
  29.     mystruct_t my_object2;
  30.    
  31.     my_object1.y;// char
  32.     my_object1.x;// int
  33.     my_object1.w;// 2 bytes
  34.    
  35.    
  36.     my_object2.y;// char
  37.     my_object2.x;// int
  38.    
  39.    
  40.  
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment