C examples for Structure:Structure Value
Passing a Structure as an Argument
#include <stdio.h> #define FUNDLEN 50/* w w w .jav a2 s . c o m*/ struct BackCount { char bank[FUNDLEN]; double bankfund; char save[FUNDLEN]; double savefund; }; double sum(struct BackCount moolah); /* argument is a structure */ int main(void){ struct BackCount stan = {"t1",1234.56,"t2",4321.21}; printf("Stan has a total of $%.2f.\n", sum(stan)); return 0; } double sum(struct BackCount moolah) { return(moolah.bankfund + moolah.savefund); }