c언어 질문????
유우
아래 소스에서 진하게 칠한데줌 설명줌 해주시고여.. 결과가 이렇게 나오는 이유줌 설명줌해주세여???
#include stdio.h
#include string.h
typedef struct {
int id;
char name[20];
float score;
} student;
void input_card(student *stu);
void print_card(student stu);
void main(void)
{
student one;
input_card(&one);
print_card(one);
}
//call by referenct
void input_card (student *stu)
{
stu-id = 12345; //(*stu).id
strcpy(stu -name, hwkang);
stu-score = 3.5;
}
//call by value
void print_card(student stu)
{
printf(ID :%d\n, stu.id);
printf(Name : %s\n,stu.name);
printf(Score : %.1f\n,stu.score);
}
답 : ID :12345
Name : hwkang
Score : 3.5
-
아리에스
구조체를 사용하는 방법은 다음과 같이 두 가지가 있습니다.
1. 구조처변수.구조체멤버변수
2. 구조체포인터변수-구조체멤버변수 -
보담
typedef struct {
int id;
char name[20];
float score;
} student;
는
struct tag {
int id;
char name[20];
float score;
};
typedef struct tag student;
와 같습니다.
\이후부터는 student라고 타입을 쓰면 struct tag 타입을 씉 것으로 알아들어라\라는 뜻이 됩니다.