delphi的,自己翻译成C吧
function SmallTOBig(small:real):string;
var 
  SmallMonth,BigMonth:string;
  wei1,qianwei1:string[2];
  wei,qianwei,dianweizhi,qian:integer;
begin
{------- 修改参数令值更精确 -------}
{小数点后的位置,需要的话也可以改动-2值}
qianwei:=-2;
{转换成货币形式,需要的话小数点后加多几个零}
Smallmonth:=formatfloat('0.00',small);
{---------------------------------}
dianweizhi :=pos('.',Smallmonth);{小数点的位置}
{循环小写货币的每一位,从小写的右边位置到左边}
for qian:=length(Smallmonth) downto 1 do
begin
{如果读到的不是小数点就继续}
if qian<>dianweizhi then
begin
{位置上的数转换成大写}
case strtoint(copy(Smallmonth,qian,1)) of
1:wei1:='壹'; 2:wei1:='贰';
3:wei1:='叁'; 4:wei1:='肆';
5:wei1:='伍'; 6:wei1:='陆';
7:wei1:='柒'; 8:wei1:='捌';
9:wei1:='玖'; 0:wei1:='零';
end;
{判断大写位置,可以继续增大到real类型的最大值}
case qianwei of
-3:qianwei1:='厘';
-2:qianwei1:='分';
-1:qianwei1:='角';
0 :qianwei1:='元';
1 :qianwei1:='拾';
2 :qianwei1:='佰';
3 :qianwei1:='千';
4 :qianwei1:='万';
5 :qianwei1:='拾';
6 :qianwei1:='佰';
7 :qianwei1:='千';
8 :qianwei1:='亿';
9 :qianwei1:='十';
10:qianwei1:='佰';
11:qianwei1:='千';
end;
inc(qianwei);
BigMonth :=wei1+qianwei1+BigMonth;{组合成大写金额}
end;
end;
SmallTOBig:=BigMonth;
end;

解决方案 »

  1.   

    贴在这里算了,首先声明,这一段不全部由本人完成,是从大富翁上检索后作修改的.
    保证可以准确把货币转成中文大写,我们已经用了一年多了.
      //小写转换大写
    function CurrToChnNum(Currnum:currency):string;
    var s:string;
    begin
      Currnum:=Currnum;
      s:=format('%11.2f',[Currnum]);
      Result := StringToChnNum(Trim(s));
    end;   function StringToChnNum(str:string):string;
    const ChnNum1='圆万亿兆';
    var i,Len,Len1,Level,Start:integer;
      s1,s:string;
      Pre: Boolean;
    begin
      Result := '';
      Len := Pos('.',str)-1;
      Level := (Len + 3) div 4 ;
      Len1 := Len mod 4 ;
      if Len1=0 then Len1 := 4;
      Start := 1;
      for i := 1 to Level
      do begin
        Pre := False;
        s := Copy(str,Start,Len1);
        s1 := FourNumToChnNum(s,'  拾佰仟',Pre);     // 注意有两个空格
        if s1<>'' then
          Result := Result + s1 + Copy(ChnNum1,(Level-i)*2+1,2);;
        Start := Start + Len1;
        Len1 := 4;
      end;
      Pre := False;
      s1 := FourNumToChnNum(Copy(str,Len+2,2),'分角',Pre);
      if s1 = '' then
        s1 := '整';
      Result := Result + s1 ;
    end;function FourNumToChnNum(Str:string;ChnNum:string;var Pre:boolean):string;
    const
      digits: array [0..9] of string = ('零','壹','贰','叁','肆',
                                           '伍','陆','柒','捌','玖');
    var i,j,Len:integer;
    begin
      Result := '';
      Len := Length(str) ;
      for i:=1 to Len
      do begin
        j := Ord(str[i])-48;
        if j=0 then
          Pre := True
        else begin
          if Pre then
            Result := Result + '零';
          Result := Result + digits[j] + Trim(Copy(ChnNum,(Len - i) * 2+1,2));
          Pre := False;
        end;
      end;
    end;
      

  2.   

    char *cUnit[7]={"分","角","元","拾","佰","仟","万"};
    char *cNumber[10]={"零","壹","贰","叁","肆","伍","陆","柒","捌","玖"};
    CString sTemp, sTemp1;
    char cTemp[5];
    BOOL ZeroFlag = FALSE;sTemp = _T("");
    sTemp1.Format("%ld", (long)(m_dTotalPrice * 100));
    for(nTemp = sTemp1.GetLength()-1; nTemp>=0; nTemp--){
    strcpy(cTemp, sTemp1.Mid(nTemp, 1));
    if(strcmp(cTemp,"-")==0){
    sTemp = "负" + sTemp;
    }
    else{
    if(atoi(cTemp) == 0){
    if ((sTemp1.GetLength()-1-nTemp) == 2)
    sTemp = cUnit[2] + sTemp;
    ZeroFlag = TRUE;
    }
    else{
    if(ZeroFlag){
    ZeroFlag = FALSE;
    if( ((sTemp1.GetLength()-1-nTemp) > 2) && (sTemp.Mid(0,2) != "元") && (sTemp.GetLength() > 0) )
    sTemp = cNumber[0] + sTemp;
    }
    sTemp = cUnit[sTemp1.GetLength()-1-nTemp] + sTemp;
    sTemp = cNumber[atoi(cTemp)] + sTemp;
    }
    }
    }
    sTemp = "币" + sTemp;