问题描述
嗨!
我有一个STL字符串,我需要将其转换为小写字母。
在VC 6中我用过:
string sInputBuffer = _strlwr((char *)sBuffer.c_str());
但是,现在在MSVC.NET 2005中我收到警告,_strlwr是
贬值。相反,它建议使用_strlwr_s:
如果我不喜欢STL,我该如何使用这个新功能?我想要
在堆上分配内存。
谢谢。
Vadim
Hi!
I have a STL string, which I need to convert to low case.
In VC 6 I used:
string sInputBuffer = _strlwr((char*)sBuffer.c_str());
However, now in MSVC.NET 2005 I am getting a warning, that _strlwr is
depricated. Instead, it''s proposed to use _strlwr_s :
http://msdn2.microsoft.com/en-us/library/y889wzfw.aspx
How should I use this new function with STL, if I don''t want to
allocate memory on heap.
Thanks.
Vadim
推荐答案
尝试这个(std C ++ - 不知道MVC):
std :: transform(sBuffer.begin(),sBuffer。 end(),sBuffer.begin(),
:: tolower);
干杯,
Andre
Try this maybe (std C++ - don''t know about MVC):
std::transform( sBuffer.begin(), sBuffer.end(), sBuffer.begin(),
::tolower );
Cheers,
Andre
您确定需要转换为小写吗?如果您想要的只是
不区分大小写的比较,您可以查看char_traits。
Are you sure you need to convert to lower case? If all you want is
case insensitive comparison you might have a look at char_traits.
V
http://groups.google.com/groups?q=co...se&qt_s=Search
V
这篇关于STL字符串 - 转换为低位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!