rpmatch(3) Library Functions Manual rpmatch(3)
NAME
rpmatch - Determines whether a response is affirmative or negative
LIBRARY
Standard C Library (libc.a)
SYNOPSIS
#include <stdlib.h>
int rpmatch( const char *response);
PARAMETERS
User input entered in response to a question that requires an affirmative or negative answer.
DESCRIPTION
The rpmatch() function determines whether the string value of the response parameter matches the affirmative or negative response expres-
sion as specified by the LC_MESSAGES category in the program's current locale. Both response expressions, defined in the locale, may be
extended regular expressions.
A possible value of the affirmative expression, yesexpr, for a English-language locale is "^([yY]|[yY][eE][sS])". This expression will
match any value of the response parameter that has consists of the letter Y (in uppercase or lowercase) or the letters YES (in any mixture
of uppercase and lowercase letters).
EXAMPLES
The following example requests a response from the user and uses the rpmatch() function to determine if the response is affirmative or neg-
ative.
#include <stdlib.h> #include <stdio.h> #include <locale.h> #include <string.h> #define SLENGTH 80
main() {
char str[SLENGTH], *eol;
int ans;
(void)setlocale(LC_ALL, "");
printf("Do you want to perform this operation: ");
fgets(str, SLENGTH, stdin);
if ((eol = strchr(str, '
')) != NULL)
*eol = '