구조체와 malloc() 함수 질문입니다.
슬아
2023.04.01
질문 제목 : malloc()구조체에서 malloc();
질문 내용 : #include stdio.h
struct person
{
char *name;
char *num;
char *local;
};
typedef struct person person;
void main()
{
person *man;
int i;
for(i = 0; i 2; i++)
{
printf(사람[%d]의 이름, 전화번호, 주소 입력 : , i+1);
scanf(%s %s %s, man[i].name, man[i].num, man[i].local);
}
for(i = 0; i 2; i++)
{
printf(\n-------------------------------------------\n);
printf(사람[%d] 이름 : %s , 전화번호 : %s, 주소 : %s \n,i+1,man[i].name, man[i].num, man[i].local);
printf(\n-------------------------------------------\n);
}
}구조체를 이용해서 두 사람의 정보를 입력 받아 출력하는겁니다..
문제는 malloc() 함수를 사용해야 하는데..
어떻게 해야할지 모르겠습니다. ㅠㅠ
도와주세요