구조체를 인자로 갖는 함수의 함수 포인터를 연습해보자.
#include <stdio.H>
#include <string.h>
typedef struct _student_t {
int no;
char name[32];
int kor;
int eng;
int math;
float avg;
} student_t;
void avg(student_t *s, int kor, int eng, int math) {
float temp= 0;
temp= (kor+eng+math)/3.0f;
(*s).avg= temp;
}
int main(void) {
student_t s1; // 정예림
student_t s2; // 정예슬
s1.no= 10;
s2.no= 11;
strcpy(s1.name, "yeo-rim");
strcpy(s2.name, "yeo-seol");
printf("[%d] %s\\n", s1.no, s1.name);
printf("[%d] %s\\n", s2.no, s2.name);
void (*fp_avg)(student_t*, int, int, int)= &avg;
fp_avg(&s1, 90, 80, 70);
printf("%s, %3.1f\\n", s1.name, s1.avg);
return 0;
}