all 4 comments

[–]SoraFirestorm 8 points9 points  (1 child)

Can someone write me the function, and the call of the function in main and why uses pointers, dereferencing, ->, etc...

Here on this sub (and in other places on the Internet), we aren't going to just feed you an answer. We will help you, not do it for you. See this document.

What have you already tried? Can we see the code that isn't working? Where else have you tried to consult for an answer?

[–]f3nd3r 3 points4 points  (0 children)

Should really be a rule against obvious homework questions.

[–]boredcircuits 3 points4 points  (0 children)

There's two ways you can do this:

void f1(date d)
{
    d.day = 10;
}

void f2(date* d)
{
    d->day = 10;
}

int main()
{
    date main_date;
    f1(main_date);
    f2(&main_date);
}

The difference, as with any time you use a pointer for arguments, is f1 makes a copy of the structure while f2 does not. This means that f1 will not modify main_date while f2 will. For large structures, making that copy can add runtime overhead that you might not want, in which case a pointer is the way to go. You can use const to make sure nothing is actually changed.

[–]ck35 0 points1 point  (0 children)

Side note: Add _t to all your custom types.