[Go to CFHT Home Page] Man Pages
Back to Software Index  BORDER=0Manpage Top Level
    strfind(3G) manual page Table of Contents

Name

strfind, strrspn, strtrns, str - string manipulations

Synopsis

cc [ flag ... ] file ... -lgen [ library ... ]

#include <libgen.h>

int strfind(const char *as1, const char *as2);

char *strrspn(const char *string, const char *tc);

char * strtrns(const char *string, const char *old, const char *new, char *result);

MT-Level

MT-Safe

Description

strfind() returns the offset of the first occurrence of the second string, as2, if it is a substring of string as1. If the second string is not a substring of the first string strfind() returns -1.

strrspn() returns a pointer to the first character in the string that is not one of the characters in tc.

strtrns() transforms string and copies it into result. Any character that appears in old is replaced with the character in the same position in new. The new result is returned.

Examples


/* find offset to substring "hello" within as1 */
i = strfind(as1, "hello");

/* trim junk from end of string */
s2 = strrspn(s1, "*?#$%");
*s2 = ’\0’;

/* transform lower case to upper case */
a1[] = "abcdefghijklmnopqrstuvwxyz";
a2[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
s2 = strtrns(s1, a1, a2, s2);

See Also

string(3C)

Notes

When compiling multi-thread applications, the _REENTRANT flag must be defined on the compile line. This flag should only be used in multi-thread applications.


Table of Contents