On 30Jun2010 12:19, Paul Rubin <no.em...@nospam.invalid> wrote: | Cameron Simpson <c...@zip.com.au> writes: | > The original V7 (and probably earlier) UNIX filesystem has 16 byte directory | > entries: 2 bytes for an inode and 14 bytes for the name. You could use 14 | > bytes of that name, and strncpy makes it effective to work with that data | > structure. | | Why not use memcpy for that?
Because when you've pulled names _out_ of the directory structure they're conventional C strings, ready for conventional C string mucking about: NUL terminated, with no expectation that any memory is allocated beyond the NUL. Think of strncpy as a conversion function. Your source is a conventional C string of unknown size, your destination is a NUL padded buffer of known size. "Copy at most n bytes of this string into the buffer, pad with NULs." Cheers, -- Cameron Simpson <c...@zip.com.au> DoD#743 http://www.cskk.ezoshosting.com/cs/ We had the experience, but missed the meaning. - T.S. Eliot -- http://mail.python.org/mailman/listinfo/python-list