Your Browser is not longer supported
Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...
{{viewport.spaceProperty.prod}}
strfill - copy substring (BS2000)
&pagelevel(4)&pagelevel
Syntax | #include <string.h> char *strfill(char *s1, const char *s2, size_t n); |
Description | strfill() copies a maximum of n characters from string s2 to the memory area pointed to by s1.
Copying takes place as described below, depending on the lengths and contents of strings s1 and s2 and the value specified for n: n characters are always copied to s1 (except in case 5), regardless of the length of string s1. In other words: If s1 contains more than n characters, the remaining characters on the right in s1 are retained. If s1 contains less than n characters, s1 is extended to the length of n. In this case, s1 is not automatically terminated with a null byte (see Notes).
s2 contains less than n characters: The required number of blanks are added to the copied characters from s2 until a total of n characters have been written. s2 contains more than n characters: Only the leading n characters from s2 are copied. s2 is empty: s1 is filled with n blanks. s2 is passed as a null pointer: (n - strlen (s1)) blanks are appended to string s1. If this subtraction yields a negative result or 0, i.e. if the number of characters in s1 is greater than or equal to n, the contents of s1 remain unchanged.
|
Return val. | Pointer to the result string s1. |
Notes | Strings terminated with the null byte (\0 ) are expected as arguments. strfill() does not verify whether s1 is large enough for the result and does not automatically terminate the result string with a null byte (\0 ). To avoid an unpredictable result, string s1 should be explicitly terminated with the null byte after every call to strfill() . The behavior is undefined if memory areas overlap. |
See also | strncpy() .
|