记录c primer plus上一个实用的字符串输入函数
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;
}
今天是我申请博客的第一天,也是写的第一篇随笔,希望自己能不忘初心,在假期结束前把c primer plus 这本书给看完。
加油!奥里给
来源:https://www.cnblogs.com/mirrormy/p/12267214.html