DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

udi_strncpy_rtrim(3udi)


Copy char array to string, removing trailing spaces

SYNOPSIS

#include <udi.h>

char *udi_strncpy_rtrim (

	char *s1,

	const char *s2,

	udi_size_t n );
 

ARGUMENTS s1 is a pointer to the destination character array string.

s2 is a pointer to the source character array, which must be at least n-bytes in size.

n is the number of bytes in s2 to be operated on (i.e., trailing spaces removed and the remaining bytes copied).

DESCRIPTION The udi_strncpy_rtrim function copies the first n bytes of the character array pointed to by s2, with trailing spaces removed, to the character array string pointed to by s1. The resulting s1 will be null terminated, with a null character (`\0') appended if necessary. The character arrays pointed to by s1 and s2 must not overlap and the destination array s1 must be large enough to receive the copy (i.e., up to n+1 bytes in size).

The source array pointed to by s2 is operated on as an n-byte character array; any embedded null characters will be copied along with other non-trailing blank characters. For example, if s2 is a 10-byte array containing the 4 characters "abcd", followed by `\0', followed by "efghi", the resulting s1 will contain the same 10 characters with an additional `\0' appended at the end. Similarly, if s2 is a 10-byte array containing the 9 characters "abcdefghi" followed by `\0', the resulting s1 will contain these 10 characters followed by an additional `\0'.


UDI Core Specification Contents