Roman Numeral Conversion API
SourceForge.net Logo
README
ChangeLog
Screen Shots
SourceForge Resources
Download
Report Bugs
Browse CVS
Man Pages
roman(7)
int2roman(3)
roman2int(3)
roman_asctime(3)
roman_ctime(3)
roman_strftime(3)
romandate(1)
romannum(1)
Examples
int2roman.c
roman2int.c
roman_asctime.c
roman_ctime.c
roman_strftime.c
 
ROMAN NUMERAL API

ROMAN NUMERAL API


NAME

int2roman, int2roman_r − convert signed int to ASCII string containing the Roman Numeral value

LIBRARY

Roman Numeral Conversion API (libroman, -lroman)

SYNOPSIS

#include <roman.h>

const char *
int2roman
(int num);

char *
int2roman_r
(int num, char * buff, size_t len);

DESCRIPTION

The function int2roman takes an argument of num and returns a pointer to a string containing the integer’s Roman Numeral representation of the integer’s value. Subsequent calls to int2roman will overwrite previous values.

The function int2roman_r provides the same functionality as int2roman, except that the caller must provide the out buffer buff to store the result. buff must be at least len characters long.

RETURN VALUES

If successful, int2roman and int2roman_r return a pointer to a string containing the Roman Numeral representation of the value of num. If there is an error, they will return a NULL pointer and set errno to indicate the error condition.

ERRORS

EDOM

num is too large to be represented using this method.

EFAULT

bad address in str

ENOBUFS

Insufficient storage space available in str.

EXAMPLES

#include <stdio.h>
#include <string.h>
#include <roman.h>

int main(int argc, char * argv[]);

int main(int argc, char * argv[])
{
int i
;
int num
;
char buff[512]
;
const char * ptr
;

for(i = 1; i < argc; i++)
{
num
= atol(argv[i]);

ptr = int2roman(num);
if
(ptr)
printf
("%i == %s\n", num, ptr);
else
perror
("int2roman_r()");

ptr = int2roman_r(num, buff, 512);
if
(ptr)
printf
("%i == %s\n", num, ptr);
else
perror
("int2roman_r()");
}

return(0);
}

REPORTING BUGS

Report bugs to <syzdek@users.sourceforge.net>.

COPYRIGHT

Copyright (C) 2007 David M. Syzdek.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

SEE ALSO

roman(7), romandate(1) romannum(1) roman2int(3) roman_ctime(3) roman_strftime(3)