전자종합설계1-이채우-과제4
- 최초 등록일
- 2014.01.01
- 최종 저작일
- 2013.04
- 5페이지/ 한컴오피스
- 가격 1,000원
목차
없음
본문내용
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct student // 명함 정보
{
char name[15];
char major[15];
char num[15];
char phone[15];
struct student *link; // linked list를 위한 포인터
}student;
student *create_student(student *P) // 사람을 늘릴 때 구조체를 생성한다.
{
student *L;
L=(student *)malloc(sizeof(student)); // 포인터를 정하고 할당을 한다.
printf("이름?");
scanf("%s",L->name);
printf("학부?");
scanf("%s",L->major);
printf("학번?");
scanf("%s",L->num);
printf("전화번호?");
scanf("%s",L->phone);
L->link=NULL; // 마지막 리스트의 방향은 항상 NULL로 향한다.
return L;
}
void display(student *head) // 전체를 출력 할 때 사용하는 함수
{
student *p=head;
while(p!=NULL) // 마지막은 항상 NULL을 가르키고 있으므로 NULL까지 움직인다.
{
printf("이름: %s\n", p->name);
printf("학부: %s\n", p->major);
printf("학번: %s\n", p->num);
printf("전화번호: %s\n\n", p->phone);
p=p->link; // 다음 리스트로 이동
<이하생략>
참고 자료
없음