char * s_gets(char *st,int n)函数返回的是一个指向char类型数组开头的指针。如果用户输入空行,数组第一个元素是’\0’,判定循环结束的条件就应该是*while(s_gets(ch,SIZE)!=’\0’)
char * s_gets(char *st,int n);//读取输入行,最多不能超过n-1个字符
printf("Enter the string(enter empty line to quit):\n");
while(*s_gets(ch,SIZE)!='\0')
{...}
char *s_gets(char *st,int n)
{
char *ret_val;
int i=0;
ret_val=fgets(st,n,stdin);
if(ret_val)
{
while (st[i]!='\n'&&st[i]!='\0')
i++;
if(st[i]=='\n') //把用户输入的换行符换成空字符
st[i]='\0';
else
while(getchar()!='\n')
continue;
}
return ret_val;
}