PI-ITBA / 2024_02

Consultas 2C 2024
4 stars 0 forks source link

Ejercicio 9 - guia 8 #104

Open JuaniRaggio opened 5 hours ago

JuaniRaggio commented 5 hours ago

Hola, como va? No me esta dando el ultimo assert, no entiendo porque.

#define offsetof(dataStructure, field) (long)(&(((dataStructure *)0)->field))

#include <assert.h>
#include <stdio.h>

typedef struct {
    int v1;
    char v2;
    char v3;
    double d1;
    char arr1[5];
} prueba;

int main(void){
    assert(offsetof(prueba, v1) == 0);
    assert(offsetof(prueba, v2) == 4);
    assert(offsetof(prueba, v3) == 5);
    assert(offsetof(prueba, d1) == 8);
    assert(offsetof(prueba, arr1[0]) == 12);
    printf("OK!");
    return 0;
}
ImNotGone commented 5 hours ago

tu double ocupa 8, asi q deberia dar 16 el ultimo assert no 12

si fuera float daria 12

JuaniRaggio commented 4 hours ago

aa buenisimo, muchas gracias