From the MSDN documentation:
The strncpy function copies the leading characters of the strSource account to strDest and returns strDest. If count is less than or equal to the length of strSource, a null character is not automatically added to the copied string. If the counter is greater than the length of strSource, the target string is filled with null characters to the length. The behavior of strncpy is undefined if the source and target lines overlap.
Note that strncpy does not check the correct destination; which remains to the programmer. Prototype:
char *strncpy( char *strDest, const char *strSource, size_t count );
Extended example:
void send250(char *inMsg, int msgLen) { char block[250]; while (msgLen > 0) { int len = (msgLen>250) ? 250 : msgLen; strncpy(block, inMsg, 250);
source share