/******************************************************************************
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby,
C#, OCaml, VB, Perl, Swift, Prolog, Javascript, Pascal, COBOL, HTML, CSS, JS
Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
#include <stdio.h>
#include <stdint.h>
typedef struct {
uint32_t potentio;
uint16_t temperature;
} capt;
int main()
{
capt c = {0xFF, 0xAAAA};
uint8_t *captptr;
capt* reconstructed_capteur;
captptr = (uint8_t*)&c;
reconstructed_capteur = (capt*) captptr;
int structsize = sizeof(capt);
printf("Structure size = %d\n", structsize);
printf("Decomposition capteur\n");
for(int i=0; i<(structsize/1); ++i) {
printf("Block %d = %d\n", i, captptr[i]);
}
printf("Recomposition capteur\n");
printf("Potentio = %d, temperature = %d", reconstructed_capteur->potentio, reconstructed_capteur->temperature);
return 0;
}