conver size_t to System::String
-
hi all new here and also to c++
MeM mem=MeM() textBoxeS[0] = gcnew System::Windows::Forms::TextBox; textBoxeS[0]->Size = System::Drawing::Size( 300, 40 ); textBoxeS[0]->ReadOnly = true; //textBoxeS[0]->Text = gcnew String(mem.X()); ???????????? textBoxeS[0]->BackColor = SystemColors::Window; MeM::MeM(void) { GlobalMemoryStatus (&stat); } System::String^ MeM::X(){ how do i cast / convert this ---->>>> char *a=(char*)stat.dwTotalPhys; return gcnew String(a); //System.ArgumentOutOfRangeExceptio //return const_cast(stat.dwTotalPhys); <<<<---------- PROBLEM HERE }
other question is there an AUTOindent function in visual C++ 2005 ? cheers rick -
hi all new here and also to c++
MeM mem=MeM() textBoxeS[0] = gcnew System::Windows::Forms::TextBox; textBoxeS[0]->Size = System::Drawing::Size( 300, 40 ); textBoxeS[0]->ReadOnly = true; //textBoxeS[0]->Text = gcnew String(mem.X()); ???????????? textBoxeS[0]->BackColor = SystemColors::Window; MeM::MeM(void) { GlobalMemoryStatus (&stat); } System::String^ MeM::X(){ how do i cast / convert this ---->>>> char *a=(char*)stat.dwTotalPhys; return gcnew String(a); //System.ArgumentOutOfRangeExceptio //return const_cast(stat.dwTotalPhys); <<<<---------- PROBLEM HERE }
other question is there an AUTOindent function in visual C++ 2005 ? cheers rickXeef wrote:
char *a=(char*)stat.dwTotalPhys;
You can't just cast a numeric to a character and then use it in string library functions because they need a null terminator. There are several C/C++/STL implementations like ltoa() and sprintf() etc. that you should research
led mike
-
hi all new here and also to c++
MeM mem=MeM() textBoxeS[0] = gcnew System::Windows::Forms::TextBox; textBoxeS[0]->Size = System::Drawing::Size( 300, 40 ); textBoxeS[0]->ReadOnly = true; //textBoxeS[0]->Text = gcnew String(mem.X()); ???????????? textBoxeS[0]->BackColor = SystemColors::Window; MeM::MeM(void) { GlobalMemoryStatus (&stat); } System::String^ MeM::X(){ how do i cast / convert this ---->>>> char *a=(char*)stat.dwTotalPhys; return gcnew String(a); //System.ArgumentOutOfRangeExceptio //return const_cast(stat.dwTotalPhys); <<<<---------- PROBLEM HERE }
other question is there an AUTOindent function in visual C++ 2005 ? cheers rickCheck out Object.ToString(). It is overridden for pretty much all base types.
System::String^ MeM::X()
{
return stat.dwTotalPhys.ToString();
}"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
-
Xeef wrote:
char *a=(char*)stat.dwTotalPhys;
You can't just cast a numeric to a character and then use it in string library functions because they need a null terminator. There are several C/C++/STL implementations like ltoa() and sprintf() etc. that you should research
led mike
-
Check out Object.ToString(). It is overridden for pretty much all base types.
System::String^ MeM::X()
{
return stat.dwTotalPhys.ToString();
}"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
-
Check out Object.ToString(). It is overridden for pretty much all base types.
System::String^ MeM::X()
{
return stat.dwTotalPhys.ToString();
}"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
-
Heh now what did I do? The OP wanted a string representation of a DWORD right? Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
-
Heh now what did I do? The OP wanted a string representation of a DWORD right? Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
-
You can call ToString on a DWORD? Let me see... Well I'll be a Fish Filet eatin goober! :laugh::laugh:
led mike
:laugh: Filet-o-Fish is on me! Yes, you can. Built in types automagically convert back and forth from managed types. You had me worried - I had to check on VS 2005 real quick (I'm still on 2003 .NET) to see if it didn't work anymore. That would have sucked :) Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder