BCD - Binary Coded Decimal

Reading time ~1 minute

C

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

extern int bcd(char *, char* );

int main(int argc, char const * argv[])
{
    size_t i = 0;
    char bcd1[] = {0x1, 0x3, 0x3, 0x8, 0xF};
    char bcd2[] = {0x8, 0x0, 0x5, 0x3, 0xF};

    bcd(bcd1, bcd2);

    while (bcd1[i] != 0xF)
    {
        printf("%"PRIX8"", bcd1[i]);
        i++;
    }
    printf("\n");

    return 0;
}