C langは:s_gets入力FOOを最適化します。

Xx_Introduction

s_gets「Cプライマープラス "最適化入力fooがあります。

Ax_Propose

キャッシュをクリアします。^ _ ^

Bx_Code

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/enomothem/p/12168640.html