STL字符串 - 转换为低位 [英] STL string - converting to low case

查看:70
本文介绍了STL字符串 - 转换为低位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!


我有一个STL字符串,我需要将其转换为小写字母。

在VC 6中我用过:

string sInputBuffer = _strlwr((char *)sBuffer.c_str());


但是,现在在MSVC.NET 2005中我收到警告,_strlwr是

贬值。相反,它建议使用_strlwr_s:
http://msdn2.microsoft.com/en-us/library/y889wzfw.aspx

如果我不喜欢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

推荐答案



Vadim写道:

Vadim wrote:
嗨!

我有一个STL字符串,我需要将其转换为小写。
在VC 6中我使用:
string sInputBuffer = _strlwr((char *)sBuffer.c_str());
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());




尝试这个(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




Vadim写道:

Vadim wrote:
嗨!

我有一个STL字符串,我需要将其转换为小写。
在VC 6中我用过:
string sInputBuffer = _strlwr((char *)sBuffer.c_str()) ;

但是,现在在MSVC.NET 2005中我收到一个警告,_strlwr已经被删除了。相反,它建议使用_strlwr_s:
http://msdn2.microsoft.com/en-us/library/y889wzfw.aspx

如果我不想,我应该如何使用STL这个新功能
在堆上分配内存。
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.




您确定需要转换为小写吗?如果您想要的只是

不区分大小写的比较,您可以查看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.


Vadim写道:
我有一个STL字符串,我需要将其转换为小写。
在VC 6中我用过:
string sInputBuffer = _strlwr((char *)sBuffer.c_str());


唉!

但是,现在在MSVC.NET 2005中我收到一个警告,_strlwr已经被删除了。相反,它建议使用_strlwr_s:
http://msdn2.microsoft.com/en-us/library/y889wzfw.aspx

如果我不想,我应该如何使用STL这个新功能
在堆上分配内存。
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());
Ugh!
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.



http://groups.google.com/groups?q=co...se&qt_s=Search


V



http://groups.google.com/groups?q=co...se&qt_s=Search

V


这篇关于STL字符串 - 转换为低位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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