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. Convert "unsigned char[8]" to long

Convert "unsigned char[8]" to long

Scheduled Pinned Locked Moved C / C++ / MFC
data-structureshelpquestion
3 Posts 2 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.
  • A Offline
    A Offline
    Abebe
    wrote on last edited by
    #1

    How do i convert a "unsigned char[8]" 8 byte array to a long. Please help. Many thnx in advance.

    X 1 Reply Last reply
    0
    • A Abebe

      How do i convert a "unsigned char[8]" 8 byte array to a long. Please help. Many thnx in advance.

      X Offline
      X Offline
      Xander80
      wrote on last edited by
      #2

      Does this example help??? Found it on http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt_atof.2c_.atoi.2c_._atoi64.2c_.atol.asp[^] char *s; long l; s = "98854 dollars"; /* Test of atol */ l = atol( s ); printf( "atol test: \"%s\"; long: %ld\n", s, l ); Output atol test: "98854 dollars"; long: 98854

      A 1 Reply Last reply
      0
      • X Xander80

        Does this example help??? Found it on http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt_atof.2c_.atoi.2c_._atoi64.2c_.atol.asp[^] char *s; long l; s = "98854 dollars"; /* Test of atol */ l = atol( s ); printf( "atol test: \"%s\"; long: %ld\n", s, l ); Output atol test: "98854 dollars"; long: 98854

        A Offline
        A Offline
        Abebe
        wrote on last edited by
        #3

        thnx for the reply, but that's not exactly what i'm looking for. I solved it by using a union. union x { unsigned char[8] ucaByteArray; double d; }; Because it's a union, they share the same address space, which means the content of all the 8 element can be accessed directly by the double. This is precisely what i want, and it works great.

        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