티스토리 뷰

C/자료구조

자체 참조 구조체

NationCore 2019. 3. 11. 16:04

#include <stdio.h>


#define MAX_NAME 50

#define MAX_STUDENTS 100


typedef struct {

int month;

int date;

} BirthdayType;


typedef struct {

char name[MAX_NAME];

BirthdayType birthday;

} student;


student students[MAX_STUDENTS];


void strcpy(char *name, char *cname)

{

while (*name = *cname)

{

name++;cname++;

}

}


void main()

{

strcpy(students[0].name, "길동차");

students[0].birthday.month = 12;

students[0].birthday.date = 25;


printf("학생 이름 : %s 생일 %d.%d\n",students[0].name,students[0].birthday.month, students[0].birthday.date);

}



결과 :



'C > 자료구조' 카테고리의 다른 글

이중 연결 리스트  (0) 2019.03.13
원형 리스트  (0) 2019.03.13
자체 참조 구조체를 이용한 동적 리스트  (0) 2019.03.13
배열을 이용한 리스트  (0) 2019.03.13
작동시간 코드  (0) 2019.03.04
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2025/07   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
글 보관함