Syntax
#include <sys/types.h> #include <regex.h> size_t regerror(int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size);Description
regerror finds the description for the error code errcode for the regular expression preg. The description for errcode is assigned to errbuf. errbuf_size is a value that you provide that specifies the maximum message size that can be stored (the size of errbuf).
Regular expressions are described in detail under "Regular Expressions" in the VisualAge C++ Programming Guide.
The description strings for errcode are:
errcode
regerror returns the size of the buffer needed to hold the string that describes the error condition.
This example compiles an invalid regular expression, and prints an error message using regerror.
#include <sys/types.h>#include <regex.h> #include <stdio.h> #include <stdlib.h> int main(void) { regex_t preg; char *pattern = "a[missing.bracket"; int rc; char buffer[100]; if (0 != (rc = regcomp(&preg, pattern, REG_EXTENDED))) { regerror(rc, &preg, buffer, 100); printf("regcomp() failed with '%s'\n", buffer); exit(EXIT_FAILURE); } return 0; /**************************************************************************** The output should be similar to : regcomp() failed with '[] imbalance' ****************************************************************************/ }Related Information