1
0

funds2.c 588 B

12345678910111213141516171819202122232425262728293031
  1. /* funds2.c -- passing a pointer to a structure */
  2. #include <stdio.h>
  3. #define FUNDLEN 50
  4. struct funds {
  5. char bank[FUNDLEN];
  6. double bankfund;
  7. char save[FUNDLEN];
  8. double savefund;
  9. };
  10. double sum(const struct funds *); /* argument is a pointer */
  11. int main(void)
  12. {
  13. struct funds stan = {
  14. "Garlic-Melon Bank",
  15. 4032.27,
  16. "Lucky's Savings and Loan",
  17. 8543.94
  18. };
  19. printf("Stan has a total of $%.2f.\n", sum(&stan));
  20. return 0;
  21. }
  22. double sum(const struct funds * money)
  23. {
  24. return(money->bankfund + money->savefund);
  25. }