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. copying an array of bytes to another array

copying an array of bytes to another array

Scheduled Pinned Locked Moved C / C++ / MFC
data-structures
8 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.
  • C Offline
    C Offline
    chaitanya22
    wrote on last edited by
    #1

    copying an array of bytes to another byte array of same size -- modified at 11:24 Friday 3rd March, 2006

    R 1 Reply Last reply
    0
    • C chaitanya22

      copying an array of bytes to another byte array of same size -- modified at 11:24 Friday 3rd March, 2006

      R Offline
      R Offline
      RChin
      wrote on last edited by
      #2

      ...and your question is? If I guess correctly, something like this would do nicely: char pArray1[] = {1,2,3,4,5}; // Source array char pArray2[5]; // Destination array memcpy(pArray1, pArray2, 5);


      I Dream of Absolute Zero

      D C 2 Replies Last reply
      0
      • R RChin

        ...and your question is? If I guess correctly, something like this would do nicely: char pArray1[] = {1,2,3,4,5}; // Source array char pArray2[5]; // Destination array memcpy(pArray1, pArray2, 5);


        I Dream of Absolute Zero

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        RChin wrote:

        memcpy(pArray1, pArray2, 5);

        Or:

        memcpy(pArray2, pArray1, 5 * sizeof(char));


        "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

        "There is no death, only a change of worlds." - Native American Proverb

        C 1 Reply Last reply
        0
        • R RChin

          ...and your question is? If I guess correctly, something like this would do nicely: char pArray1[] = {1,2,3,4,5}; // Source array char pArray2[5]; // Destination array memcpy(pArray1, pArray2, 5);


          I Dream of Absolute Zero

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

          Its an array of Bytes, like i owuld like like to assign source array of bytes to destination array, as am getting chunks of bytes in the source array, so that i would be having all bytes without break.

          D 1 Reply Last reply
          0
          • D David Crow

            RChin wrote:

            memcpy(pArray1, pArray2, 5);

            Or:

            memcpy(pArray2, pArray1, 5 * sizeof(char));


            "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

            "There is no death, only a change of worlds." - Native American Proverb

            C Offline
            C Offline
            chaitanya22
            wrote on last edited by
            #5

            ya thank you, it didnt work for me, i would like to assign source array to new array. eg: assinging BYTE sourcearray[212] to BYTE destarray[1024],,,, as am pieces of bytes in source array, like 108 bytes for the first time and again 104 bytes for the second time. -- modified at 11:57 Friday 3rd March, 2006

            D 1 Reply Last reply
            0
            • C chaitanya22

              Its an array of Bytes, like i owuld like like to assign source array of bytes to destination array, as am getting chunks of bytes in the source array, so that i would be having all bytes without break.

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              memcpy() is the function to use. What about it is not working?


              "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

              "There is no death, only a change of worlds." - Native American Proverb

              C 1 Reply Last reply
              0
              • D David Crow

                memcpy() is the function to use. What about it is not working?


                "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                "There is no death, only a change of worlds." - Native American Proverb

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

                yes, its working, but again am getting the breaks in the data as like in source array. I would like to have continous stream of data.

                1 Reply Last reply
                0
                • C chaitanya22

                  ya thank you, it didnt work for me, i would like to assign source array to new array. eg: assinging BYTE sourcearray[212] to BYTE destarray[1024],,,, as am pieces of bytes in source array, like 108 bytes for the first time and again 104 bytes for the second time. -- modified at 11:57 Friday 3rd March, 2006

                  D Offline
                  D Offline
                  David Crow
                  wrote on last edited by
                  #8

                  chaitanya22 wrote:

                  i would like to assign source array to new array. eg: assinging BYTE sourcearray[212] to BYTE destarray[1024],,,,

                  Use:

                  memcpy(destarray, sourcearray, 108 * sizeof(BYTE));


                  "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                  "There is no death, only a change of worlds." - Native American Proverb

                  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