Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- typedef struct {
- char name[100];
- int age;
- char sex;
- } PERSONAL;
- void personal_input(PERSONAL data[]);
- void personal_output(PERSONAL data[]);
- int main(void) {
- PERSONAL data[3];
- personal_input(data);
- personal_output(data);
- return 0;
- }
- void personal_input(PERSONAL data[]) {
- int i;
- for (i = 0; i < 3; i++) {
- printf("名前:");
- scanf("%99[^\n]%*[^\n]", data[i].name);
- getchar();
- printf("年齢:");
- scanf("%d%*c", &data[i].age);
- printf("性別:");
- scanf("%c%*c", &data[i].sex);
- }
- }
- void personal_output(PERSONAL data[]) {
- int i;
- for (i = 0; i < 3; i++) {
- printf("名前:%s\n", data[i].name);
- printf("年齢:%d\n", data[i].age);
- printf("性別:%c\n", data[i].sex);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement