WCHAR tmp[100];
double value = -41.999;
    wsprintf(tmp, TEXT(" res: %f"), value);
    SetWindowText(hCtrlStatic, tmp);怎么也扫不到tmp里面,晕!!!最近看不了msdn,郁闷,是不是没有XP及时更新?
如果我想得到 -42怎么办?如果是 -41.0000003,我想得到-41怎么办? 多谢了。

解决方案 »

  1.   

    MFC里
        CString str;
        str.Format("res:%0.3f",-41.999);
        SetDlgItemText(id, -41.999);
      

  2.   

    MFC里 
        CString str; 
        str.Format("res:%0.0f",-41.999); 
        SetDlgItemText(id, -41.999);
      

  3.   

    MFC里 
        CString str; 
        double value = -41.999; 
        str.Format("res:%0.0f", value ); 
        SetDlgItemText(id, LPCTSTR(str));
      

  4.   

    WCHAR tmp[100]; 
    double value = -41.999; 
        swprintf(tmp, TEXT(" res: %.0f"), ceil(value)); 
      

  5.   

    错了,不需要ceil。
    WCHAR tmp[100]; 
    double value = -41.009; 
        swprintf(tmp, TEXT(" res: %.0f"), value); 
      

  6.   


    多谢多谢,满分!!!
    可惜看不了msdn,兄台可否再随便解释下这个%.0f和为什么不要用wsprintf?
    看书说wsprintf是windows下的版本,但是干什么用的呢?
      

  7.   

    wsprintf只能输出字符,字符串和整型数据,要输出任意类型应该用swprintfint wsprintf( 
      LPTSTR lpOut, 
      LPCTSTR lpFmt, 
      ...
    );
    Res
    A format specification has the following form: %[-][#][0][width][.precision]typeThe type characters that appear after the last optional format field determine whether the associated argument is interpreted as a character, a string, or a number.
      

  8.   

    嘻嘻 swprintf那格式怎么写呢
      

  9.   

    wsprintf和swprintf是不同的
    1个是stl的,1个是mfc的,swprintf可以有%f
      

  10.   

     WCHAR tmp[100];    
      double value = -41.009;    
      swprintf(tmp,  "%f", value);