您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

在C语言中模仿Python的strip()函数

在C语言中模仿Python的strip()函数

对于strip()或trim()函数,没有标准的C实现。就是说,这是Linux内核中包含的一个

char *strstrip(char *s)
{
        size_t size;
        char *end;

        size = strlen(s);

        if (!size)
                return s;

        end = s + size - 1;
        while (end >= s && isspace(*end))
                end--;
        *(end + 1) = '\0';

        while (*s && isspace(*s))
                s++;

        return s;
}
python 2022/1/1 18:45:39 有706人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶