在变换中使用tolower [英] Using tolower in transform

查看:45
本文介绍了在变换中使用tolower的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


i无法使用tolower()函数:


#include< algorithm>

#include< iostream>

#include< locale>

#include< string>


使用std :: cout;

使用std :: ctype;

使用std :: endl;

使用std :: locale;

使用std :: string;

使用std :: transform;

使用std :: use_facet;


typedef ctype< char> char_ctype_facet;


int

main()

{

locale loc("" );

const char_ctype_facet& ct = use_facet< char_ctype_facet>(loc);

string str(Hello world。);


transform(str.begin(),str.end (),

str.begin(),ct.tolower);


cout<< str<< endl;

返回0;

}


$ g ++ -W -Wall -std = c ++ 98 -pedantic tolower .cc

tolower.cc:在函数`int main()'':

tolower.cc:24:错误:没有匹配的函数来调用

`transform(__ gnu_cxx :: __ normal_iterator< char *,std :: basic_string< char,

std :: char_traits< char>,std :: allocator< char>>>,

__gnu_cxx :: __ normal_iterator< char *,std :: basic_string< char,

std :: char_traits< char> ;, std :: allocator< char>>> ,

__gnu_cxx :: __ normal_iterator< char *,std :: basic_string< char,

std :: char_traits< char> ;, std :: allocator< char>>> ;,<未知类型>)''


ct.tolower是< unknow type>


我做错了什么?


-

TheDD

Hello,

i don''t manage to use the tolower() function:

#include <algorithm>
#include <iostream>
#include <locale>
#include <string>

using std::cout;
using std::ctype;
using std::endl;
using std::locale;
using std::string;
using std::transform;
using std::use_facet;

typedef ctype< char > char_ctype_facet;

int
main()
{
locale loc("");
const char_ctype_facet& ct = use_facet< char_ctype_facet >(loc);
string str("Hello world.");

transform(str.begin(), str.end(),
str.begin(), ct.tolower);

cout << str << endl;
return 0;
}

$ g++ -W -Wall -std=c++98 -pedantic tolower.cc
tolower.cc: In function `int main()'':
tolower.cc:24: error: no matching function for call to
`transform(__gnu_cxx::__normal_iterator<char*, std::basic_string<char,
std::char_traits<char>, std::allocator<char> > >,
__gnu_cxx::__normal_iterator<char*, std::basic_string<char,
std::char_traits<char>, std::allocator<char> > >,
__gnu_cxx::__normal_iterator<char*, std::basic_string<char,
std::char_traits<char>, std::allocator<char> > >, <unknown type>)''

ct.tolower is <unknow type>

What am i doing wrong?

--
TheDD

推荐答案

g ++ -W -Wall -std = c ++ 98 -pedantic tolower.cc

tolower.cc:在功能上`int main()'':

tolower.cc:24:错误:没有匹配函数来调用

`transform(__ gnu_cxx :: __ normal_iterator< char *,std :: basic_string< char,

std :: char_traits< char> ;,std :: allocator< char> > >,

__gnu_cxx :: __ normal_iterator< char *,std :: basic_string< char,

std :: char_traits< char> ;,std :: allocator< char> > >,

__gnu_cxx :: __ normal_iterator< char *,std :: basic_string< char,

std :: char_traits< char> ;,std :: allocator< char> > >,<未知类型>)''


ct.tolower是< unknow type>


我做错了什么?


-

TheDD
g++ -W -Wall -std=c++98 -pedantic tolower.cc
tolower.cc: In function `int main()'':
tolower.cc:24: error: no matching function for call to
`transform(__gnu_cxx::__normal_iterator<char*, std::basic_string<char,
std::char_traits<char>, std::allocator<char> > >,
__gnu_cxx::__normal_iterator<char*, std::basic_string<char,
std::char_traits<char>, std::allocator<char> > >,
__gnu_cxx::__normal_iterator<char*, std::basic_string<char,
std::char_traits<char>, std::allocator<char> > >, <unknown type>)''

ct.tolower is <unknow type>

What am i doing wrong?

--
TheDD


TheDD写道:
TheDD wrote:
你好,

我没有设法使用tolower()函数:

#include< algorithm>
#include< iostream> ;
#include< locale>
#include< string>

使用std :: cout;
使用std :: ctype;
使用std :: endl;
使用std :: locale;
使用std :: string;
使用std :: transform;
使用std :: use_facet;

typedef ctype< char> char_ctype_facet;

int
main()
{locale loc("");
const char_ctype_facet& ct = use_facet< char_ctype_facet>(loc);
string str(Hello world。);

transform(str.begin(),str.end(),
str .begin(),ct.tolower);


不会

转换(str.begin(),str.end(),str.begin(),tolower) ;


诀窍?

cout<< str<< endl;
返回0;
}

Hello,

i don''t manage to use the tolower() function:

#include <algorithm>
#include <iostream>
#include <locale>
#include <string>

using std::cout;
using std::ctype;
using std::endl;
using std::locale;
using std::string;
using std::transform;
using std::use_facet;

typedef ctype< char > char_ctype_facet;

int
main()
{
locale loc("");
const char_ctype_facet& ct = use_facet< char_ctype_facet >(loc);
string str("Hello world.");

transform(str.begin(), str.end(),
str.begin(), ct.tolower);
Wouldn''t

transform(str.begin(), str.end(), str.begin(), tolower);

do the trick?

cout << str << endl;
return 0;
}


g ++ -W -Wall -std = c ++ 98 -pedantic tolower.cc
tolower.cc:在函数`int main()'':
tolower.cc:24:错误:没有匹配函数来调用
`transform(__ gnu_cxx :: __ normal_iterator< char * ,std :: basic_string< char,
std :: char_traits< char> ;,std :: allocator< char>>>,
__ gn_cxx :: __ normal_iterator< char *,std :: basic_string< char ,
std :: char_traits< char>,std :: allocator< char>>>,
__gnu_cxx :: __ normal_iterator< char *,std :: basic_string< char,
std: :char_traits< char>,std :: allocator< char>>>,<未知类型>)''

ct.tolower是< unknow type>
我做错了什么?
g++ -W -Wall -std=c++98 -pedantic tolower.cc
tolower.cc: In function `int main()'':
tolower.cc:24: error: no matching function for call to
`transform(__gnu_cxx::__normal_iterator<char*, std::basic_string<char,
std::char_traits<char>, std::allocator<char> > >,
__gnu_cxx::__normal_iterator<char*, std::basic_string<char,
std::char_traits<char>, std::allocator<char> > >,
__gnu_cxx::__normal_iterator<char*, std::basic_string<char,
std::char_traits<char>, std::allocator<char> > >, <unknown type>)''

ct.tolower is <unknow type>

What am i doing wrong?




不确定。


Victor



Not sure.

Victor

这篇关于在变换中使用tolower的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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