beautypg.com

Strncpy, Strpbrk, Strncpy strpbrk – Zilog ZUSBOPTS User Manual

Page 475: Synopsis, Returns, Example

background image

UM017105-0511

Standard Functions

Zilog Developer Studio II – ZNEO™

User Manual

447

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

Returns

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

Example

char *ptr;

char s1[]="COMPASS";

char s2[]="PASS";

ptr=strpbrk(s1,s2);

This manual is related to the following products: