Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. conver size_t to System::String

conver size_t to System::String

Scheduled Pinned Locked Moved Managed C++/CLI
questionc++graphicshelp
9 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X Offline
    X Offline
    Xeef
    wrote on last edited by
    #1

    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

    L M 2 Replies Last reply
    0
    • X Xeef

      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

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      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

      X 1 Reply Last reply
      0
      • X Xeef

        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

        M Offline
        M Offline
        Mark Salsbery
        wrote on last edited by
        #3

        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

        X L 2 Replies Last reply
        0
        • L led mike

          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

          X Offline
          X Offline
          Xeef
          wrote on last edited by
          #4

          cool ! thx a lot ! working so fare :-D System::String^ MeM::X(){ char a[200]; sprintf_s( a,200, "%d", stat.dwTotalPhys ); return gcnew System::String(a); }

          1 Reply Last reply
          0
          • M Mark Salsbery

            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

            X Offline
            X Offline
            Xeef
            wrote on last edited by
            #5

            wow so much help in so short time thank you too

            1 Reply Last reply
            0
            • M Mark Salsbery

              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

              L Offline
              L Offline
              led mike
              wrote on last edited by
              #6

              Mark Salsbery wrote:

              stat.dwTotalPhys.ToString();

              :wtf::confused:

              led mike

              M 1 Reply Last reply
              0
              • L led mike

                Mark Salsbery wrote:

                stat.dwTotalPhys.ToString();

                :wtf::confused:

                led mike

                M Offline
                M Offline
                Mark Salsbery
                wrote on last edited by
                #7

                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

                L 1 Reply Last reply
                0
                • M Mark Salsbery

                  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

                  L Offline
                  L Offline
                  led mike
                  wrote on last edited by
                  #8

                  You can call ToString on a DWORD? Let me see... Well I'll be a Fish Filet eatin goober! :laugh::laugh:

                  led mike

                  M 1 Reply Last reply
                  0
                  • L led mike

                    You can call ToString on a DWORD? Let me see... Well I'll be a Fish Filet eatin goober! :laugh::laugh:

                    led mike

                    M Offline
                    M Offline
                    Mark Salsbery
                    wrote on last edited by
                    #9

                    :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

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups