Common solution is to store the value in cents as an `int`, and have a function that translates this internal representation to something that most people are more used to seeing.
Maybe something like this:
Code:
// Code not necessarily correct or guaranteed to compile.
#include <stdio.h>
int dprice(int* dollars, int* cents, const int price);
int main(void)
{
int price = 410;
int dollars, cents;
if ( dprice(&dollars, ¢s, price) != -1) {
printf("Price of widget is $%d.%d\n", dollars, cents);
} else {
printf("Something happened. We're sorry!");
return 1;
}
return 0;
}
int dprice(int* dollars, int* cents, const int price)
{
if (d == NULL || c == NULL)
return -1;
*dollars = price / 100; // `int` division discards the reminder
*cents = price % 100; // whatever's left is the cents part
return 0;
}