User Profile

Advertisement

  • Add Friend
  • Add Note
  • Track User
  • Send Message
  • Send V-Gift
Userpic

Dont Even.

hurry

Created on 2004-02-22 18:10:57 (#2301750), last updated 2004-05-04

60 comments received, 44 comments posted

Basic Info
Name:alphabetizethis
Birthdate:06-23
Location:Philadelphia, Pennsylvania, United States
Bio

strncpy was first designed to handle a now-obsolete data structure, the fixed-length, not-necessarily-\0-terminated ``string.'' (A related quirk of strncpy's is that it pads short strings with multiple \0's, out to the specified length.) strncpy is admittedly a bit cumbersome to use in other contexts, since you must often append a '\0' to the destination string by hand. You can get around the problem by using strncat instead of strncpy: if the destination string starts out empty, strncat does what you probably wanted strncpy to do. Another possibility is sprintf(dest, "%.*s", n, source) .

When arbitrary bytes (as opposed to strings) are being copied, memcpy is usually a more appropriate routine to use than strncpy.
Connect
Friends [View Entries]
Communities [View Entries]

Watching (0)

Feeds [View Entries]

Watching (0)

Advertisement

Create an Account
Forgot your login or password?
Login w/ OpenID
English • Español • Deutsch • Русский…