ITPub博客

首页 > > > toupper()的参数只能是整型?

toupper()的参数只能是整型?

作者:z_paul 时间:2019-09-03 11:33:56 0 删除 编辑
#include<iostream>
#include<string>
#include<vector>
#include<cctype>

int main()
{
    std::vector<std::string> str{ "some string" };

    for (auto i = str.begin(); i != str.end() && !i->empty(); i++)
    {
        *i = toupper(*i);
        std::cout << *i;
    }
    std::cout <<  std::endl;
    return 0;
}

代码如上,我试过把std::vector<std::string>改为std::string,那样的话可以解决toupper的问题,但i->empty()出现错误。嗯,还请各位多多指教。

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/75/viewspace-3139726/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-07-17

  • 博文量
    151
  • 访问量
    6023