beautypg.com

Strncat, Strncmp, Strncat strncmp – Zilog ZUSBOPTS User Manual

Page 474: Synopsis, Returns, Example

background image

Standard Functions

UM017105-0511

446

Zilog Developer Studio II – ZNEO™
User Manual

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, const 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(const char *s1, const 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";

int res;

res=strncmp(s1,s2,3);

This manual is related to the following products: