第一次写博客

记录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 这本书给看完。

加油!奥里给

posted @ 2020-02-05 23:11  我想去故宫  阅读(111)  评论(0)    收藏  举报