C语言学习7

结构体数组:实现简易通讯录

 1 #include <stdio.h>
 2 #include <stdlib.h>
 3 
 4 #define NUM 3
 5 
 6 struct person
 7 {
 8     char name[20];
 9     char phone[10];
10 };
11 
12 void main()
13 {
14     struct person man[NUM];
15     int i;
16 
17     for(i = 0; i<NUM; i++)
18     {
19         printf("input name:
");
20         gets(man[i].name);
21         printf("input phone:
");
22         gets(man[i].phone);
23     }
24     printf("	name						phone
");
25 
26     for(i = 0; i<NUM; i++)
27     {
28         printf("%20s			%20s
", man[i].name, man[i].phone);
29     }
30     system("pause");
31 }
原文地址:https://www.cnblogs.com/wangkeqi/p/9373196.html