typo
This commit is contained in:
parent
792e993185
commit
7c1c36d9ea
@ -5,7 +5,7 @@
|
||||
|
||||
#### Ex1
|
||||
|
||||
Compilez avec `g++` le programme [alignement.c](./src/alignement.c), et
|
||||
Compilez avec `g++` le programme [structure.c](./src/structure.c), et
|
||||
exécutez. Vérifiez qie la taille et l'alignement de chaque structure est bien
|
||||
conforme aux règles vues en cours.
|
||||
|
||||
|
38
tp/tp1/src/structure.c
Normal file
38
tp/tp1/src/structure.c
Normal file
@ -0,0 +1,38 @@
|
||||
#include <stdio.h>
|
||||
|
||||
struct
|
||||
{
|
||||
float x;
|
||||
char n[1];
|
||||
} s1;
|
||||
|
||||
struct
|
||||
{
|
||||
short s;
|
||||
char n[3];
|
||||
} s2;
|
||||
|
||||
struct s3
|
||||
{
|
||||
char Data1;
|
||||
short Data2;
|
||||
int Data3;
|
||||
char Data4;
|
||||
} s3;
|
||||
|
||||
struct
|
||||
{
|
||||
char Data1;
|
||||
char Data4;
|
||||
short Data2;
|
||||
int Data3;
|
||||
} s4;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
printf("s1 : alignement = %d\ntaille = %d\n",alignof(s1), sizeof(s1));
|
||||
printf("s2 : alignement = %d\ntaille = %d\n",alignof(s2), sizeof(s2));
|
||||
printf("s3 : alignement = %d\ntaille = %d\n",alignof(s3), sizeof(s3));
|
||||
printf("s4 : alignement = %d\ntaille = %d\n",alignof(s4), sizeof(s4));
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user