beautypg.com

Strncpy, Strpbrk, Strncpy strpbrk – Zilog EZ80F916 User Manual

Page 388

background image

UM014423-0607

C Standard Library

ZiLOG Developer Studio II

eZ80Acclaim!

®

User Manual

368

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);

strncpy

Copies not more than n characters from the string pointed to by s2 to the array pointed to
by s1. If copying takes place between objects that overlap, the behavior is undefined.

If the string pointed to by s2 is shorter than n characters, null characters are appended to
the copy in the array pointed to by s1, until n characters in all have been written.

Synopsis

#include
char *strncpy(char *s1, char *s2, size_t n);

Returns

The value of s1.

Example

char *ptr;
char s1[40]="Production";
char s2[]="Languages";
ptr=strncpy(s1,s2,4);

strpbrk

Locates the first occurrence in the string pointed to by s1 of any character from the string
pointed to by s2.

Synopsis

#include
char *strpbrk(char *s1, char *s2);

Returns

A pointer to the character, or a null pointer if no character from s2 occurs in s1.

This manual is related to the following products: