beautypg.com

Strncat, Strncmp, Strncat strncmp – Zilog Z8F0130 User Manual

Page 491

background image

UM013037-1212

strncat

Zilog Developer Studio II – Z8 Encore!

User Manual

467

Example

char s1[]="COMPASS";

int i;

i=strlen(s1);

strncat

Appends no more than n characters of the string pointed to by s2 (not including the termi-
nating null character) to the end of the string pointed to by s1. The initial character of s2
overwrites the null character at the end of s1. A terminating null character is always
appended to the result.

Synopsis

#include

char *strncat(char *s1, char *s2, size_t n);

Returns

The value of s1.

Example

char *ptr;

char strl[80]="Production";

char str2[]="Languages";

ptr=strncat(str1,str2,4);

strncmp

Compares no more than n characters from the string pointed to by s1 to the string pointed
to by s2.

Synopsis

#include

int strncmp(char *s1, char *s2, size_t n);

Returns

An integer greater than, equal to, or less than zero, according as the string pointed to by s1
is greater than, equal to, or less than the string pointed to by s2.

Example

char s1[]="Production";

char s2[]="Programming";