구조체 함수 에러나요 도와주세요
빗줄기
#include stdio.hstruct date {
int month;
int day;
int year;
};
struct student {
int number;
char name[20];
double height;
struct date *dob;
};
void print(struct student *s,struct student *t)
{ printf(학번: %d\n, s-number);
printf(이름: %s\n, s-name);
printf(신장: %f\n, s-height);
printf(생년월일: %d년 %d월 %d일\n, s-dob-year, s-dob-month, s-dob-day);
printf(학번: %d\n, t-number);
printf(이름: %s\n, t-name);
printf(신장: %f\n, t-height);
printf(생년월일: %d년 %d월 %d일\n, t-dob-year, t-dob-month, t-dob-day);
};
int main()
{
struct date d = { 3, 20, 1980 };
struct student *s { 123456, 홍길동, 160 };
s-dob=&d;
struct date d1 = { 10, 10, 1992 };
struct student *t = { 111111, 아무게, 160 };
t-dob=&d1;
print(struct student s, struct student t);
return 0;
}지금 하는중인데 에러가 나요 답답해요 도와주세요 헬프미!
-
갤쓰리
흠...리스트로해서 연결해서 관리 하심되요..
어떤의도로 소스를 짜신건지 몰라서 일단은 되게만했는데.... -
청력
음 .. 데이터 구조체를 저렇게 선언해도 되나요 ??
멜럭 함수 사용하는것도 제가 아는거랑 다르네요 되는거겟죠 ? -
재찬
일단 되게는 했는데 이런 의도는 아닌가요???
메인을 이렇게만 바꾸면되는데....흠....
int main()
{
\tdate d = { 3, 20, 1980 };
\tstudent *s;
\ts = (student*)malloc(sizeof(student));
\ts-number = 123456;
\tstrcpy(s-name,\홍길동\);
\ts-height = 160;
\ts-dob = &d;
\tprint(s,s);\t
\tfree(s);
-
다슬
글씨체 바꾸시구요, 컴파일 에러 메시지를 잘 읽어보세요.