/* * * Demonstrate passing a structure as a function argument */ #include struct data { float amount; char fname[30]; char lname[30]; } rec; void print_rec(struct data x); int main() { /* Declare and define a structure to hold the data*/ /* The function prototype; the function has no return * value and it takes a structure of type data as its one * argument */ /* Input the data from the keyboard */ printf("Enter the donor's first and last name, \n"); printf("separated by a space: "); scanf("%s %s", rec.fname, rec.lname); printf("\nEnter the donation amount: "); scanf("%f", &rec.amount); /* Call the display function */ print_rec(rec); return 0; } void print_rec(struct data x) { printf("\nDonor %s %s gave $%.2f.\n", x.fname, x.lname, x.amount); }