Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C memcpy in reverse

Tags:

c

reverse

memcpy

I am working with audio data. I'd like to play the sample file in reverse. The data is stored as unsigned ints and packed nice and tight. Is there a way to call memcpy that will copy in reverse order. i.e. if I had 1,2,3,4 stored in an array, could I call memcpy and magically reverse them so I get 4,3,2,1.

like image 211
Aran Mulholland Avatar asked Feb 11 '10 05:02

Aran Mulholland


1 Answers

No, memcpy won't do that backwards. If you're working in C, write a function to do it. If you're really working in C++ use std::reverse or std::reverse_copy.

like image 115
janm Avatar answered Sep 21 '22 06:09

janm