strupr() and strlwr() in string.h part are of the ANSI standard?

白昼怎懂夜的黑 提交于 2019-11-26 23:17:29

They are non-standard functions from Microsoft's C library. MS has since deprecated them in favor of renamed funcitons _strlwr() and _strupr():

Note that the MS docs claim they are POSIX functions, but as far as I can tell they never have been.

If you need to use them on a non-MS toolchain, they're easy enough to implement.

char* strlwr(char* s)
{
    char* tmp = s;

    for (;*tmp;++tmp) {
        *tmp = tolower((unsigned char) *tmp);
    }

    return s;
}

These functions are not C standard functions. So it is implementation-defined whether they are supported or not.

These functions are not standard, and in fact their signatures are broken/non-usable. You cannot case-map a string in-place in general, because the length may change under case mapping.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!