// Punteros a struct: el operador -> sigue el puntero y elige el campo.
#include <stdio.h>

struct product {
    int stock;
    double price;
};

void restock(struct product *item, int amount) {
    (*item).stock = (*item).stock + amount;
}

void discount(struct product *item, double percent) {
    item->price = item->price * (100 - percent) / 100;
}

double total_value(const struct product *item) {
    return item->stock * item->price;
}

int main(void) {
    struct product rice = {10, 4.50};

    restock(&rice, 5);
    discount(&rice, 20);
    printf("stock %d, precio %.2f, total %.2f\n", rice.stock, rice.price, total_value(&rice));
    printf("sizeof(rice) = %zu, sizeof(&rice) = %zu\n", sizeof(rice), sizeof(&rice));
    return 0;
}
