반응형
#include<iostream>
using namespace std;
struct Info
{
char name[20];//이름
char hp[11];//전화번호
int age;//나이
};
//입력함수
struct Info inputInfo( struct Info *info);
//출력함수
void showprint(struct Info *showinfo);//출력
int main(void)
{
struct Info personInfo[3] ={};
struct Info *pp;
pp=&personInfo[0];
cout<<"개인신상정보"<<endl;
for (int i=0;i<3;i++)
{
pp[i]=inputInfo(&personInfo[i]);
}
for (int i=0;i<3;i++)
{
showprint(&personInfo[i]);
}
return 0;
}
Info inputInfo( struct Info *info)
{
cout<<"신상정보를 입력하세요.."<<endl<<endl;
char name[20];
cout<<"이름 : ";
cin>>name;
strcpy(info->name,name);
cout<<"전화번호 : ";
cin>>info->hp;
cout<<"나이 입력: ";
cin>>info->age;
return *info;
}
void showprint(struct Info *showinfo)
{
cout<<"신상정보출력"<<endl;
cout<<"이름"<<showinfo->name<<endl;
cout<<"전화번호"<<showinfo->hp<<endl;
cout<<"나이"<<showinfo->age<<endl;
}
반응형