C 语言自定义函数

1、

  char  * s_gets(char * st, int n)

  {

    char * ret_val;

    char * find;

    

    ret_val = fgets(st, n, stdin);

    if (ret_val)

    {

       find = strchr(st, '\n');

      if (find)

        *find = '\0';

      else 

        while (getchar() != '\n')

          continue;

    }

    return ret_val;

  }

猜你喜欢

转载自www.cnblogs.com/moxiaoyu557/p/10715816.html