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. C / C++ / MFC
  4. unsigned long to string

unsigned long to string

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
8 Posts 5 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.
  • C Offline
    C Offline
    Caoimh
    wrote on last edited by
    #1

    Hi previously I asked how to convert string to unsigned long now the reverse is required. How would I convert unsigned long to string? HAVE: unsigned long cnt = FFFF0000; REQUIRE: a string with the value "FFFF0000" suggestions much appreciated Kind Regards Kevin

    J P R 3 Replies Last reply
    0
    • C Caoimh

      Hi previously I asked how to convert string to unsigned long now the reverse is required. How would I convert unsigned long to string? HAVE: unsigned long cnt = FFFF0000; REQUIRE: a string with the value "FFFF0000" suggestions much appreciated Kind Regards Kevin

      J Offline
      J Offline
      jmkhael
      wrote on last edited by
      #2

      char acBuffer[128]={0}; sprintf(acBuffer, "%d", uLong); Check the format specification for more info u might need %ud Papa while (TRUE) Papa.WillLove ( Bebe ) ;

      C 1 Reply Last reply
      0
      • C Caoimh

        Hi previously I asked how to convert string to unsigned long now the reverse is required. How would I convert unsigned long to string? HAVE: unsigned long cnt = FFFF0000; REQUIRE: a string with the value "FFFF0000" suggestions much appreciated Kind Regards Kevin

        P Offline
        P Offline
        Prakash Nadar
        wrote on last edited by
        #3

        I assume you are using MFC. cnd = 0xFFFF0000; CString strValue; strValue.Format("%X",cnt);


        MSN Messenger. prakashnadar@msn.com

        C 1 Reply Last reply
        0
        • J jmkhael

          char acBuffer[128]={0}; sprintf(acBuffer, "%d", uLong); Check the format specification for more info u might need %ud Papa while (TRUE) Papa.WillLove ( Bebe ) ;

          C Offline
          C Offline
          Caoimh
          wrote on last edited by
          #4

          My string is type CString not a character array. Any Ideas??

          J R 2 Replies Last reply
          0
          • C Caoimh

            Hi previously I asked how to convert string to unsigned long now the reverse is required. How would I convert unsigned long to string? HAVE: unsigned long cnt = FFFF0000; REQUIRE: a string with the value "FFFF0000" suggestions much appreciated Kind Regards Kevin

            R Offline
            R Offline
            Rory Solley
            wrote on last edited by
            #5

            You could use the standard library: unsigned long cnt = 0xFFFF0000; TCHAR tszString[16]; // Arbitrary size _stprintf(tszString, _T("%8.8X"), cnt); Sorry, just read your CString post: CString strString; strString.Format(_T("%8.8X"), cnt);

            1 Reply Last reply
            0
            • C Caoimh

              My string is type CString not a character array. Any Ideas??

              J Offline
              J Offline
              jmkhael
              wrote on last edited by
              #6

              CString temp; temp.Format("%ud", uLong); Papa while (TRUE) Papa.WillLove ( Bebe ) ;

              1 Reply Last reply
              0
              • P Prakash Nadar

                I assume you are using MFC. cnd = 0xFFFF0000; CString strValue; strValue.Format("%X",cnt);


                MSN Messenger. prakashnadar@msn.com

                C Offline
                C Offline
                Caoimh
                wrote on last edited by
                #7

                Sorted, Thank You.

                1 Reply Last reply
                0
                • C Caoimh

                  My string is type CString not a character array. Any Ideas??

                  R Offline
                  R Offline
                  Roger Allen
                  wrote on last edited by
                  #8

                  CString text; text.Format("%ux", cnt); Roger Allen - Sonork 100.10016 Roger Wright: Remember to buckle up, please, and encourage your friends to do the same. It's not just about saving your life, but saving the quality of life for those you may leave behind...

                  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