BOOTSTRAP (kutils) functions
LIBRARY ROUTINE
kstrncat - concatenate up to n characters on a string
LIBRARY CALL
char *kstrncat(
char *ostr,
const char *istr,
size_t num)
INPUT
- ostr - The base string to concatenate.
- istr - The string to concatenate to the base.
- num - The number of characters in 'istr' to concat
onto 'ostr'. If the specified number is larger
than the length of istr, then this function stops
at the null character. If 'num' is less than or
equal to zero, 'ostr' is left unchanged.
OUTPUT
- ostr - The resulting combined output string.
RETURN VALUE
A pointer to the concatenated string 'ostr' after 'num'
characters of 'istr' are appended onto the end of 'ostr'.
It will return NULL, if 'ostr' is NULL. If 'istr' is
NULL or num is less than or equal to zero, 'ostr' is
returned unchanged.
DESCRIPTION
This function concatenates a specified number of characters
one string to another. This function is similar to
system call strncat(). kstrncat() appends upto 'num'
characters from 'istr' to the end of 'ostr'.
Note that the calling routine must make sure that 'ostr'
points to a memory buffer large enough to hold the
concatenated string and terminating null character.
If the buffer is not large enough, memory will be
overwritten resulting in unpredicable program failure.
ADDITIONAL INFORMATION
none
EXAMPLES
This example partially combines two strings into a
familiar saying.
char *s1 = "I'm sorry Dave. ";
char *s2 = "I'm afraid I can't do that. It is too complicated.";
char result[KLENGTH];
kstrcpy(result, s1);
s1 = kstrncat(result, s2, 27);
kprintf("%s\n", s1);
The output is 'I'm sorry Dave. I'm afraid I can't do that.'
SIDE EFFECTS
none
RESTRICTIONS
none
MODIFICATION
none
FILES
$BOOTSTRAP/objects/library/kutils/src/strings.c
SEE ALSO
kutils(3)
COPYRIGHT
Copyright (C) 1993 - 1997, Khoral Research, Inc. ("KRI") All rights reserved.