Passing structure members as arguments - C Structure

C examples for Structure:Structure Value

Description

Passing structure members as arguments

Demo Code

#include <stdio.h>
#define FUNDLEN 50//w ww. ja va 2  s  .c  o m

struct BackCount {
    char   bank[FUNDLEN];
    double bankfund;
    char   save[FUNDLEN];
    double savefund;
};

double sum(double, double);

int main(void){
    struct BackCount stan = {"t2",1234.56,"t1",7654.12};
    
    printf("Stan has a total of $%.2f.\n", sum(stan.bankfund, stan.savefund) );
    return 0;
}

double sum(double x, double y){
    return(x + y);
}

Result


Related Tutorials