编辑数值金额成中文金额Linux认证考试
文章作者 100test 发表时间 2009:10:22 22:00:58
来源 100Test.Com百考试题网
/*
* Function Name: edit_money
* Description :编辑数值金额成中文金额
* Input : char * in --输入的数值字符串
*
* Output : char * out --输出的中文金额
* Return :
*/
void
edit_money( char * in, char * out )
{
char s1[256], s2[ 10 ]. int i, j, k, l, n, len1.
char * p_dot.
char chn_digit[11][3] = { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" }. char chn_unit1[4][3] = { "", "拾", "佰", "仟" }. char chn_unit2[3][5] = { "万", "亿", "万亿" }.
if ( in == NULL || out == NULL )
return.
if ( strlen( in ) == 0 )
return.
memset(s1,0x00,sizeof(s1)). strncpy( s1, in, sizeof(s1) ).
/*判断是否有小数点*/
p_dot = strchr( s1, . ).
if ( p_dot == NULL )
s2[0] = 0x0.
else
{
memset(s2,0x00,sizeof(s2)). strcpy( s2, p_dot 1 ).
*p_dot = 0x0.
}