I'm trying to print the outcome of the function below
void add_votes(struct votes* v1, struct votes* v2) {
v1->men += v2->men;
v1->women += v2->women;
}
With this set of code
add_votes(all, michigan);
printf("all->men: %d\n", &(all->men);
Here are all needed variables and structure
struct votes {
int men;
int women;
};
struct votes *michigan = {200, 300};
struct votes *all = {0, 0};
I tried placing an & before the cast in the printf but after a second printf it displays the address of the pointer and when I print it without a & it doesn't display nothing
If it’s supposed to be a pointer how should I do it And if I remove the & from the print it says a series of number I guess the address but I need the value It says something like 1303720 when I need it to be 200 or something like that
printf("all->men: %d\n", all->men);You don't care about the address at all. Note, though, that you are not correctly initializing your pointer variables; they have to point to something.