• 코드:
​x
 
1
#include <stdio.h>
2
​
3
typedef struct
4
{
5
    int savings;
6
    int loan;   
7
} PROP;
8
​
9
int calcProperty(PROP*);
10
​
11
int main(void)
12
{
13
    int hong_prop;
14
    PROP hong = {10000000, 4000000};
15
    
16
    hong_prop = calcProperty(&hong);    // 구조체의 주소를 함수의 인수로 전달함. 
17
    
18
    printf("홍길동의 재산은 적금 %d원에 대출 %d원을 제외한 총 %d원입니다.\n", hong.savings, hong.loan, hong_prop);
19
    return 0;
20
}
21
​
22
int calcProperty(PROP* money)
23
{
24
    money->savings = 100;   // 호출된 함수에서 원본 구조체의 데이터를 변경
25
    return (money->savings - money->loan);
26
}
27
​
표준입력 & 실행옵션