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. Copy Buffer in reverse order.

Copy Buffer in reverse order.

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
5 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.
  • N Offline
    N Offline
    Neha
    wrote on last edited by
    #1

    Hi, I have buffer,i would like to store it to another buffer in a reverse order.I mean last byte of source buffer should be the first byte of destination buffer. can any one help me for this? Neha

    PJ ArendsP 1 Reply Last reply
    0
    • N Neha

      Hi, I have buffer,i would like to store it to another buffer in a reverse order.I mean last byte of source buffer should be the first byte of destination buffer. can any one help me for this? Neha

      PJ ArendsP Offline
      PJ ArendsP Offline
      PJ Arends
      wrote on last edited by
      #2

      BYTE buf1[100];
      BYTE buf2[100];

      for (int x = 0; x < 100; x++)
      {

      = buf1[99 - x];

      }

      HTH :) --- CPUA 0x5041 Sonork 100.11743 Chicken Little It may be that your sole purpose in life is simply to serve as a warning to others.

      Within you lies the power for good; Use it!

      N 1 Reply Last reply
      0
      • PJ ArendsP PJ Arends

        BYTE buf1[100];
        BYTE buf2[100];

        for (int x = 0; x < 100; x++)
        {

        = buf1[99 - x];

        }

        HTH :) --- CPUA 0x5041 Sonork 100.11743 Chicken Little It may be that your sole purpose in life is simply to serve as a warning to others.

        N Offline
        N Offline
        Neha
        wrote on last edited by
        #3

        But in my case buffer is a memory pointer. Is there any api which copies the memory buffer is reverse order?

        H PJ ArendsP 2 Replies Last reply
        0
        • N Neha

          But in my case buffer is a memory pointer. Is there any api which copies the memory buffer is reverse order?

          H Offline
          H Offline
          hkprs
          wrote on last edited by
          #4

          hi, I am not sure of any api that copies Mem Buffer in reverse order but may be u can use "memcpy" , " memccpy" or "memmove" which copy in the orginal order. May be U can reverse them from local buff... Hope this Helps... hkprs

          1 Reply Last reply
          0
          • N Neha

            But in my case buffer is a memory pointer. Is there any api which copies the memory buffer is reverse order?

            PJ ArendsP Offline
            PJ ArendsP Offline
            PJ Arends
            wrote on last edited by
            #5

            _strrev(), or in STL template<class BidirectionalIterator> inline void reverse(BidirectionalIterator first, BidirectionalIterator last) or

            void reverse (BYTE *src, BYTE *dest, size_t size)
            { // copy the first size bytes from src to dest in reverse order
            for (int x = 0; x < size; x++)
            {

            = src[size - 1 - x];

            }
            }

            --- CPUA 0x5041 Sonork 100.11743 Chicken Little It may be that your sole purpose in life is simply to serve as a warning to others.

            Within you lies the power for good; Use it!

            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