将char数组转换为受管系统字符串 [英] Convert a char array to a managed system string
问题描述
你好!
我一直在努力寻找一种方法将
a终止的char数组转换为系统::在Visual C ++ .NET中使用的字符串
2003.
这是必要的,因为我有一些需要处理的legcay C代码
a字符串取自文本框,然后我需要重新显示字符串为
textbox-> Text。我很容易找到如何从system :: string转换为char []
,但我不知道如何转向其他方式!!
有人能指出我正确的方向吗?我是VC ++的新手
托管编程和整个GUI的东西! :S
" Trep" <哒********** @ gmail.com>写道:
你好!
我一直在努力寻找一种方法来解决将终止的char数组转换为用于Visual C ++ .NET的系统::字符串的方法。<2003。 / blockquote>
C ++没有system :: string,但是在模拟std :: string
system :: string s = the_char_array;
值得一试。
Okaaay ...首先,让我为我的
初始中的残暴拼写道歉帖子。它现在还很早,我的大脑有点小!
我应该花时间进行拼写检查。
对不起:(
Trep写道:你好!
我一直在很难找到一种方法将终止的char数组转换为系统::字符串,以便在Visual C ++ .NET中使用
2003.
这是必要的,因为我有一些legcay C代码需要处理从文本框中取出的字符串,然后我需要重新显示字符串作为
textbox-> Text。我很容易找到如何从系统转换::字符串到char []
但我不知道怎么走另一条路!!
有人能指出我正确的方向吗?我很新到VC ++
托管编程和整个GUI的东西!:S
on t opic(当然不是任何系统特定的库,比如ADO .NET
或者其他)。
在任何情况下,如果你想将std :: string转换为"炭[]"调用
c.str()成员函数就足够了。
C ++ / CLI中的示例:
std :: string s =" ;测试" ;;
字符串^ someString = gcnew字符串(s.c_str());
字符串otherString(s.c_str() );
[
关闭主题:
在当前的托管扩展程序中:
std :: string s =" Test";
String * someString = __gc new String(s.c_str());
]
-
Ioannis Vranos
http://www23.brinkster.com/noicys
Hi there!
I''ve been having a lot of difficult trying to figure out a way to convert
a terminated char array to a system::string for use in Visual C++ .NET
2003.
This is necessary because I have some legcay C code that needs to process
a string taken from a textbox, then I need to re-display the string as the
textbox->Text. I easily found how to convert from system::string to char[]
but I can''t figure out how to go the other way!!
Can someone point me in the right direction? I''m pretty new to VC++
managed programming and the whole GUI thing! :S
解决方案"Trep" <da**********@gmail.com> writes:
Hi there! I''ve been having a lot of difficult trying to figure out a way to convert
a terminated char array to a system::string for use in Visual C++ .NET
2003.
C++ doesn''t have system::string, but on the analogu of std::string
system::string s = the_char_array;
is worth trying.
Okaaay... first off, let me just apologize for the atrocious spelling in my
initial post. It''s still pretty early here and my brain is a little zapped!
I should have taken the time to run a spell-check.
Sorry :(
Trep wrote:Hi there!
I''ve been having a lot of difficult trying to figure out a way to convert
a terminated char array to a system::string for use in Visual C++ .NET
2003.
This is necessary because I have some legcay C code that needs to process
a string taken from a textbox, then I need to re-display the string as the
textbox->Text. I easily found how to convert from system::string to char[]
but I can''t figure out how to go the other way!!
Can someone point me in the right direction? I''m pretty new to VC++
managed programming and the whole GUI thing! :S
..NET is entirely off topic here, however in the future C++/CLI will be
on topic (but not any system specific libraries of course, like ADO .NET
or whatever).
In any case, if you want to convert an std::string to "char[]" a call to
c.str() member function will suffice.
Example in C++/CLI:
std::string s="Test";
String ^someString= gcnew String(s.c_str());
String otherString(s.c_str());
[
Off topic:
In current "managed extensions":
std::string s="Test";
String *someString= __gc new String(s.c_str());
]
--
Ioannis Vranos
http://www23.brinkster.com/noicys
这篇关于将char数组转换为受管系统字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!