How can I use function call in this situation?

In my code, I have a typedef struct like this:

1
2
3
4
  typedef struct {
	double balance;  //US $ amount remaining in your account.
	double coins;    //Number of coins you own. (usually a fraction).
} Account;


Then the value of balance and coins are assigned in this function.

1
2
3
4
5
void print(Account * account)
{
	account->balance = 0.0;
	account->coins = 0.0;
}


Now, the problem here is that i'm trying to call the function "print(Account * account)" in main function to display the balance and coins.
How exactly can I do it?

I'm not good at describing a problem and also a C++ beginner. Any help will be much appreciated. Thank you in advance!
1
2
3
4
5
6
int main() { 
  // Create an Account named a
  Account a;
  // Give the function print the address of that account:
  print(&a);
}


A reasonable assumption is that a function named print actually prints something. Use a better name, or at least one which is not misleading.

Last edited on
Thank you so much for your help! I tried and it worked.
Topic archived. No new replies allowed.