Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3634126
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T00:44:25+00:00 2026-05-19T00:44:25+00:00

I’m looking for cross-platform library which I can use in my C application to

  • 0

I’m looking for cross-platform library which I can use in my C application to convert money amounts (e.g. $123.50) to words (one hundred twenty three dollars and fifty cents). I need support for multiple currencies: dollars, euros, UK pounds etc.

Although I understand this is not hard at all to write my own implementation, but I’d like to avoid reinventing wheel. I’ve tried to google it, but there is too much noise related to MS Word converters.

Can anybody suggest something?

UPDATE numerous comments suggest to write my own implementation because it’s really easy task. And I agree. My point was about support of multiple currencies in the same time and different business rules to spell the amounts (should be fractional part written as text or numbers? etc.) As I understand serious business applications have such library inside, but I think there is nothing open-source available, maybe because it seems as very easy task.

I’m going to write my own libary and then open-source it. Thanks to all.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T00:44:26+00:00Added an answer on May 19, 2026 at 12:44 am

    Are you looking for something like this? It’s not a complete solution as it externalizes the handling of the currency. Furthermore, it fails for negative numbers.

    Just allocate a character buffer and call write_number. The third and fourth argument are expected to be the currency units (in their plural form), e.g. “dollars” and “cents”. (The singular case isn’t properly handled yet.

    #include <math.h>
    #include <string.h>
    
    const char* SMALL_NUMBERS[] = {
        0, "one ", "two ", "three ", "four ",
        "five ", "six ", "seven ", "eight ", "nine ",
        "ten ", "eleven ", "twelve ", "thirteen ", "fourteen ",
        "fiftenn ", "sixteen ", "seventeen ", "eighteen ", "nineteen "
    };
    
    const char* TENS[] = {
        0, 0, "twenty ", "thirty ", "forty ",
        "fifty ", "sixty ", "seventy ", "eighty ", "ninety "
    };
    
    
    void append_lt_1000(char* buf, int num)
    {
        if (num >= 100) {
            strcat(buf, SMALL_NUMBERS[num / 100]);
            strcat(buf, "hundred ");
            num %= 100;
        }
        if (num >= 20) {
            strcat(buf, TENS[num / 10]);
            num %= 10;
        }
        if (num != 0)
            strcat(buf, SMALL_NUMBERS[num]);
    }
    
    void append_mag(char* buf, double* number, double magnitude, const char* mag_name)
    {
        if (*number < magnitude)
            return;
    
        append_lt_1000(buf, (int)(*number / magnitude));
        strcat(buf, mag_name);
        *number = fmod(*number, magnitude);
    }
    
    void write_number(char* buf, double number, const char* major_unit, const char* minor_unit)
    {
        double ip, fp;
    
        buf[0] = 0;
        fp = modf(number, &ip);
    
        if (ip == 0) {
            strcat(buf, "zero ");
        } else {
            append_mag(buf, &ip, 1000000000000.0, "trillion ");
            append_mag(buf, &ip, 1000000000.0, "billion ");
            append_mag(buf, &ip, 1000000, "million ");
            append_mag(buf, &ip, 1000, "thousand ");
            append_lt_1000(buf, (int)ip);
        }
        strcat(buf, major_unit);
    
        if (fp != 0) {
            strcat(buf, " and ");
            append_lt_1000(buf, (int)(fp * 100));
            strcat(buf, minor_unit);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I'm looking for suggestions for debugging... If you view this site in Firefox or
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker
Seemingly simple, but I cannot find anything relevant on the web. What is the
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.