strupr()和string.h中部分str​​lwr()是ANSI标准的? [英] strupr() and strlwr() in string.h part are of the ANSI standard?

查看:154
本文介绍了strupr()和string.h中部分str​​lwr()是ANSI标准的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找这对互联网和符合string.h中这两个都没有提到的功能,每一个地方。

I was looking for this on internet and in every place with the functions of string.h these two are not mentioned.

是因为什么?他们不是在每一个编译器?

Is because what? They aren't in every compiler?

推荐答案

他们是来自微软的C库非标准功能。 MS此后德$ P $赞成改名funcitons的pcated它们 _strlwr() _strupr()

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

  • strlwr() doc
  • strupr() doc

请注意,MS文档声称他们是POSIX的功能,但据我可以告诉他们永远都没有。

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

如果您需要使用它们在非MS工具链,他们是很容易的实现。

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;
}

这篇关于strupr()和string.h中部分str​​lwr()是ANSI标准的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆