Chapter Contents |
Previous |
Next |
strrcspn |
Portability: | SAS/C extension |
SYNOPSIS | |
DESCRIPTION | |
RETURN VALUE | |
CAUTION | |
EXAMPLE | |
RELATED FUNCTIONS | |
SEE ALSO |
SYNOPSIS |
#include <lcstring.h> size_t strrcspn(const char *str, const char *cset);
DESCRIPTION |
strrcspn
scans the input string (
str
) for the last
occurrence of any character in the search set (
cset
). The
strrcspn
function is
the reverse of
strcspn
.
RETURN VALUE |
strrcspn
returns the number of characters in the argument string up to and including
the last occurrence of any character in the search set.
If no character in the search set can be found in the
input string, the value returned is 0. If the search set is null (that is,
if it contains no characters), the return value from
strrcspn
is the length of the input string.
CAUTION |
EXAMPLE |
#include <lcstring.h> #include <stdio.h> void main() { char *text, input[80]; size_t len; int i; puts("Enter a line of text:"); text = gets(input); /* Find the last blank space or punctuation */ /* character in a line terminated by '\0'. */ len = strrcspn(text, ",.\"?;':!"); /* Write to stdout all text after the last */ /* punctuation character or space in the */ /* string (which might not be a word). */ for(i = len; text[i] != '\0' && text[i] != '\n'; i++) putchar(text[i]); putchar('\n'); }
RELATED FUNCTIONS |
SEE ALSO |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.