r305_dm/Exo5/alignement.c
2023-09-13 15:57:45 +02:00

56 lines
690 B
C

/* alignement et objets */
struct exemple1 {
int x;
int y;
int z;
int w;
};
struct exemple2 {
char x;
char y;
char z;
char w;
};
struct exemple3 {
int x;
int y;
char z;
char w;
};
struct exemple4 {
int x;
char y;
int z;
char w;
};
union exemple5 {
int x;
char y;
int z;
char w;
};
int main()
{
int a[4] = {1,2,3,4};
char c[4] = {'a','b','c','d'};
struct exemple1 ex1 = {1,2,3,4};
struct exemple2 ex2 = {'a','b','c','d'};
struct exemple3 ex3 = {1,2,'c','d'};
struct exemple4 ex4 = {1,'c',2,'d'};
union exemple5 ex5;
int x = 61;
char y = 62;
int z = 63;
char w = 64;
ex5.x=62;ex5.y=63;ex5.z=64;ex5.w=65;
// appelez hexdump pour chaque variable
}