write from buffer to buffer

hey guys, i was hoping that there was a way to do an operation, like fwrite(), except instead of buffer to file, from buffer to buffer. for instance, you could do
buffer_write(initial_buffer_pointer, number_of_bytes, final_buffer_pointer)

and it would write that many bytes from buffer to buffer. does it exist?

thanks, much appreciated!
memcpy() in <cstring> does just that

1
2
3
4
5
6
7
8
#include <cstring>

//..

int ar1[5] = {0,1,2,3,4};
int ar2[5];

memcpy( ar2, ar1, sizeof(int) * 5 );
great! that works perfectly. thankyou very much!
If you are using C++, you can use the char_traits<> class instead of #including the old <cstring> library
1
2
3
4
5
6
#include <string>

int ar1[5] = {0,1,2,3,4};
int ar2[5];

char_traits <int> ::copy( ar2, ar1, 5 );

This code is otherwise identical to that which Disch posted.
Topic archived. No new replies allowed.