![]() |
![]()
| ![]() |
![]()
NAMExt_romantoi() - Convert Roman numeral string to int LIBRARY#include <xtend/stdlib.h> -lxtend SYNOPSISint xt_romantoi(const char *string, char **endptr) ARGUMENTSstring: Pointer to the first character of the Roman numeral endptr: Address of a pointer variable to receive the end of the string DESCRIPTIONThe xt_romantoi() function converts a string containing a valid Roman numeral to an integer, much like strtol(). It rejects non-normalized values, such as IIIII, XXXXX, or CCCCC, which should be written as V, L, and D, respectively. IIII, XXXX, and CCCC are accepted in place of IV, XL, and CD. Any number of consecutive Ms (1000s) are accepted, since there is no larger digit. Like strtol(), it returns the address of the first character not converted as part of the number. This can be used to verify that the number ended as it should have, perhaps with a '0' byte. RETURN VALUESThe integer value of the Roman numeral if converted, or 0 if an invalid numeral is detected. EXAMPLESchar string[] = "XIV", *end; int n; n = xt_romantoi(string, &end); if ( *end == '0' ) SEE ALSOstrtol(3)
|