C
[C] 121 구조체를 함수에서 사용하기
qkrwngus
2021. 1. 30. 21:47
Desc :
Source Code :
#include <stdio.h>
#include <string.h>
void print(struct tagStaff *pone);
struct tagStaff
{
char name[10];
char phone[20];
char address[100];
};
void main()
{
struct tagStaff one;
struct tagStaff *pone;
pone = &one;
strcpy((*pone).name, "홍길동");
strcpy((*pone).phone, "010-1234-5678");
strcpy((*pone).address, "서울시 강남구");
print(&one);
}
void print(struct tagStaff *pone)
{
printf("이름: %s\n", pone->name);
printf("전화: %s\n", pone->phone);
printf("주소: %s\n", pone->address);
}
Result :
안올라가져서 섞여버렸다,,,,,,,,,,,,,, 안돼,,,,,,,,,,,,,,,,,,,