Re: Doubt in memcpy() and memset()



Shhnwz.a wrote:

I want to know some of the situations , when to use memcpy() and when
to memset();

Can't you tell from their descriptions?

memcpy( void *s1, const void *s2, size_t n );

... copies n characters from the object pointed to by s2
into the object pointed to by s1. If copying takes place
between objects that overlap, the behaviour is undefined.

memset( void *s, int c, size_t n );

... copies the value of c (converted to an unsigned char)
into each of the first n characters of the object pointed
to by s.

Use whichever one fits your situation.

--
Chris "Perikles triumphant" Dollin
"No-one here is exactly what he appears." G'kar, /Babylon 5/

.



Relevant Pages

  • Re: ATWT - Leaving? (re: SPOILERS FOR THE WEEK OF JUNE 30th)
    ... Is Chris leaving the show? ... squandering the children of the veteran characters, ... Cyrus caught him with Daisy, and much longer for Cassie to find out, ... confront Cyrus, get Daisy to hide him and steal from her family, sleep ...
    (rec.arts.tv.soaps.cbs)
  • Re: "We lead the world in computerized data collection!" (Sopranos spoilers)
    ... The Chris stuff actually bored me way more than Artie. ... interested in characters like Vito, Benny, and Chris' rehab buddy(can't ... The guy who hung himself in the first episode was absolutely ...
    (rec.music.phish)
  • Re: Narrow To Wide To Narrow String Conversion With reinterpret_cast
    ... so it will keep reading memory until it ... | NUL-terminated array of single-byte characters to an 0x0000- ... | terminated array of two-byte characters. ... Chris Val ...
    (alt.comp.lang.learn.c-cpp)
  • Re: A++ == B: Always True?
    ... Chris> I think you missed the point of Michael's response. ... Chris> doesn't have at least the basic ASCII characters (even ... If you can't generally trust the compiler to implement the Java ... about a fundamental difference between the languages that he was ...
    (comp.lang.java.programmer)
  • RE: Using non-printable characters in passwords
    ... Chris: Subject: RE: Using non-printable characters in passwords ... hash represents only 7 characters, meaning that if you have a 21 character ... it is really 3 consecutive 7 character passwords. ...
    (Security-Basics)