BOOTSTRAP (kutils) functions


LIBRARY ROUTINE

kstrcpy - copy a string

LIBRARY CALL

char *kstrcpy(
   char       *ostr,
   const char *istr)

INPUT

OUTPUT

RETURN VALUE

A pointer to the copied string 'ostr' after 'istr' is copied to 'ostr'. If 'istr' is NULL, 'ostr' is returned without modification. If 'ostr' is NULL, then NULL is returned.

DESCRIPTION

This function copies one string to another. This function is similar to system call strcpy(). kstrcpy() is used used to copy each character in the input string to the output string. The terminating null character of the input string is copied so that the input and output strings are exact copies. Thus, 'ostr' is overwritten.

Note that the calling routine must ensure that 'ostr' points to a memory buffer large enough to hold the copied 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

The following example copies strings 's1' to 's2'.
char  s2[KLENGTH];
char *s1 = "Hello World.\n";
char *result;

result = kstrcpy(s2, s1); kprintf("%s", result);

The output is a single line saying 'Hello World', and the pointer 'result' is pointing to the 's2' array.

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.