Microchip Technology XC8 Standard Compiler (Workstation) SW006021-1 SW006021-1 User Manual

Product codes
SW006021-1
Page of 518
Library Functions
 2012 Microchip Technology Inc.
DS52053B-page 365
STRNCAT 
Synopsis
#include <string.h>
 
char * strncat (char * s1, const char * s2, size_t n)
Description
This function appends (concatenates) string 
s2
 to the end of string 
s1
. At most 
n
 char-
acters will be copied, and the result will be null terminated. 
s1
 must point to a character 
array big enough to hold the resultant string.
Example
#include <string.h>
#include <stdio.h>
void 
main (void)
{
    char buffer[256];
    char * s1, * s2;
    strcpy(buffer, "Start of line");
    s1 = buffer;
    s2 = "... end of line";
    strncat(s1, s2, 5);
    printf("Length = %d\n", strlen(buffer));
    printf("string = \"%s\"\n", buffer);
}
See Also
strcpy()
, strcmp(), strcat(), strlen()
Return Value
The value of 
s1
 is returned.
STRNCMP, STRNICMP 
Synopsis
#include <string.h>
 
int strncmp (const char * s1, const char * s2, size_t n)
int strnicmp (const char * s1, const char * s2, size_t n)
Description
The 
strncmp()
 function compares its two, null terminated, string arguments, up to a 
maximum of 
n
 characters, and returns a signed integer to indicate whether 
s1
 is less 
than, equal to or greater than 
s2
. The comparison is done with the standard collating 
sequence, which is that of the ASCII character set.
The 
strnicmp()
 function is the case-insensitive version of this function.