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. Accessing/Assigning data buffer from pointer

Accessing/Assigning data buffer from pointer

Scheduled Pinned Locked Moved C / C++ / MFC
questiondatabaseperformance
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.
  • B Offline
    B Offline
    billiam904
    wrote on last edited by
    #1

    I am converting a wave file for which my boss gave me the calculations for. I have two PUCHAR buffers alloocated with GLOBALALLOC. One is input buffer which I have loaded from the file, the other is an output buffer which I will store the converted data into. The buffers are defined as follows: PUCHAR m_pbyDemoBuffer; PWORD m_pwOutDemoAudio; I need to convert m_pbyDemoBuffer to 16-bit (PWORD), then perform calculation on it before storing it in m_pwOutDemoAudio. I need to do this by indexing each 16-bit element. My question is, how do I convert the input buffer to PWORD and how would I assign the value (plus whatever calculations I make) of index 0 of m_pbyDemoBuffer to the value of index 0 of m_pwDemoOutAudio? My boss is having me do the following: m_pwDemoOutAudio[0] = m_pbyDemoInBuffer[0] * 128 I think this is wrong because both variables are pointers. Wouldn't the above code assign the "memory address times 128" to m_pwDemoOutAudio? Thanks. Bill Dennis Orlando, FL

    S 1 Reply Last reply
    0
    • B billiam904

      I am converting a wave file for which my boss gave me the calculations for. I have two PUCHAR buffers alloocated with GLOBALALLOC. One is input buffer which I have loaded from the file, the other is an output buffer which I will store the converted data into. The buffers are defined as follows: PUCHAR m_pbyDemoBuffer; PWORD m_pwOutDemoAudio; I need to convert m_pbyDemoBuffer to 16-bit (PWORD), then perform calculation on it before storing it in m_pwOutDemoAudio. I need to do this by indexing each 16-bit element. My question is, how do I convert the input buffer to PWORD and how would I assign the value (plus whatever calculations I make) of index 0 of m_pbyDemoBuffer to the value of index 0 of m_pwDemoOutAudio? My boss is having me do the following: m_pwDemoOutAudio[0] = m_pbyDemoInBuffer[0] * 128 I think this is wrong because both variables are pointers. Wouldn't the above code assign the "memory address times 128" to m_pwDemoOutAudio? Thanks. Bill Dennis Orlando, FL

      S Offline
      S Offline
      S Senthil Kumar
      wrote on last edited by
      #2

      billiam904 wrote: Wouldn't the above code assign the "memory address times 128" to m_pwDemoOutAudio? It won't. If the code was m_pbyDemoInBuffer * 128, then you'd be correct. m_pbyDemoInBuffer[0] is the same as *(m_pbyDemoInBuffer + 0), so yeah, it does access whatever is pointed to by m_pbyDemoInBuffer. Regards Senthil _____________________________ My Blog | My Articles | WinMacro

      B 1 Reply Last reply
      0
      • S S Senthil Kumar

        billiam904 wrote: Wouldn't the above code assign the "memory address times 128" to m_pwDemoOutAudio? It won't. If the code was m_pbyDemoInBuffer * 128, then you'd be correct. m_pbyDemoInBuffer[0] is the same as *(m_pbyDemoInBuffer + 0), so yeah, it does access whatever is pointed to by m_pbyDemoInBuffer. Regards Senthil _____________________________ My Blog | My Articles | WinMacro

        B Offline
        B Offline
        billiam904
        wrote on last edited by
        #3

        Thank you. I got it working and you cleared some things up. Bill Dennis Orlando, FL

        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