728x90
반응형
문제 : http://www.jungol.co.kr/bbs/board.php?bo_table=pbank&wr_id=95&sca=10g0
문제
이름과 전화번호, 주소를 멤버로하는 구조체를 정의하여 1개의 자료를 입력받고 출력하는 프로그램을 작성하시오. 각각의 길이는 100자 이하다.
입력 예
Lim 1234-5678 Seoul
출력 예
name : Lim
tel : 1234-5678
addr : Seoul
Hint!
전화번호는 문자열로 처리하는 것이 편리하고 일반적이다.
코드 :
# include <stdio.h>
typedef struct Person{
char name[101];
char tell[101];
char address[101];
}Person;
int main()
{
Person a1;
scanf("%s %s %s",a1.name,a1.tell,a1.address);
printf("name : %s\n",a1.name);
printf("tel : %s\n",a1.tell);
printf("addr : %s\n",a1.address);
return 0;
}
728x90
반응형
최근댓글