beautypg.com

Strrchr, Strspn, Strstr – Zilog Z8F0130 User Manual

Page 493: Strrchr strspn strstr

background image

UM013037-1212

strrchr

Zilog Developer Studio II – Z8 Encore!

User Manual

469

strrchr

Locates the last occurrence of c (converted to a

char

) in the string pointed to by s. The

terminating null character is considered to be part of the string.

Synopsis

#include

char *strrchr(char *s, int c);

Returns

A pointer to the character, or a null pointer if c does not occur in the string.

Example

char *ptr;

char s1[]="COMPASS";

ptr=strrchr(s1,'p');

strspn

Finds the first substring from a given character set in a string.

Synopsis

#include

size_t strspn(char *s1, char *s2);

Returns

The length of the segment.

Example

char s1[]="cabbage";

char s2[]="abc";

size_t res;

res=strspn(s1,s2);

strstr

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

Synopsis

#include

char *strstr(char *s1, char *s2);