Afficher un message
Vieux 06/02/2008, 15h33   #2
Alf P. Steinbach
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Replacement for memcpy call in C++

* mthread:
> I am copying data from one buffer(this data is a binary data not
> string) to another buffer. Earlier when I used C, I used the memcpy
> function call to copy the values. Is there any equivalent replacement
> in C++ for this call.


If for example your buffers are

char* buffer1;
char* buffer2;

then in C++ the natural way would be to use vectors instead,

std::vector<char> buffer1;
std::vector<char> buffer2;

then to copy just assign,

buffer1 = buffer2;

In some situations it may be necessary to do something like mempcy
instead of choosing a more convenient representation, and then consider
std::copy.


Cheers, & hth.,

- Alf

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
  Réponse avec citation
 
Page generated in 0,05429 seconds with 9 queries