diff options
| author | Mosder <xmosder12@gmail.com> | 2026-07-22 01:16:45 +0200 |
|---|---|---|
| committer | Mosder <xmosder12@gmail.com> | 2026-07-22 01:16:45 +0200 |
| commit | 5d463a7f4c721629a1996be6d19634338290a539 (patch) | |
| tree | 5c681a524990ad8b181dea567d6dc7629d01e8c9 /analyzer/utils/roman.c | |
| parent | 1f664d5b6396fb24c8ce4990ba8882118abb8dcd (diff) | |
refactor: generalized parser structs with offsetof and put them into separate files
Diffstat (limited to 'analyzer/utils/roman.c')
| -rw-r--r-- | analyzer/utils/roman.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/analyzer/utils/roman.c b/analyzer/utils/roman.c index 9ea2bbb..4fbe5c0 100644 --- a/analyzer/utils/roman.c +++ b/analyzer/utils/roman.c @@ -1,16 +1,15 @@ #include "utils/roman.h" -#include <stddef.h> #include <string.h> +#include "utils/memory.h" + void to_roman(char *buffer, int number) { buffer[0] = '\0'; - int nums[ROMAN_CHAR_COUNT] = ROMAN_NUMS; - char *chars[ROMAN_CHAR_COUNT] = ROMAN_CHARS; - for (size_t i = 0; i < ROMAN_CHAR_COUNT; i++) { - for (size_t j = 0; j < number / nums[i]; j++) { - strcat(buffer, chars[i]); + for (size_t i = 0; i < ARR_LEN(roman_symbols); i++) { + for (size_t j = 0; j < number / roman_symbols[i].num; j++) { + strcat(buffer, roman_symbols[i].symbol); } - number %= nums[i]; + number %= roman_symbols[i].num; } } |
