1 /*-----------------------------------------
2 names_st.c -- 定义 names_st.h 中的函数
3 -----------------------------------------*/
4
5 #include <stdio.h>
6 #include "names_st.h" //包含头文件
7
8 //函数定义
9 void get_names(names *pn)
10 {
11 printf("Please enter your first name: ");
12 s_gets(pn->first, SLEN);
13
14 printf("Please enter your last name: ");
15 s_gets(pn->last, SLEN);
16 }
17
18 void show_names(const names *pn)
19 {
20 printf("%s %s", pn->first, pn->last);
21 }
22
23 char* s_gets(char *st, int n)
24 {
25 char *ret_val, *find;
26
27 if (ret_val = fgets(st, n, stdin))
28 {
29 if (find = strchr(st, '
'))
30 *find = '