【问题标题】:How to write INT64 to CString如何将 INT64 写入 CString
【发布时间】:2011-03-05 07:54:17
【问题描述】:

我在 C++ 窗口中编码。

INT64 dirID = -1;
CString querySQLStr = _T("");
querySQLStr.Format(L"select * from ImageInfo where FolderPath=%64d;", dirID);

querySQLStr always like this:
select * from ImageInfo where FolderPath=                                                            1214;

使用%64d对吗? 非常感谢

【问题讨论】:

    标签: c++ windows mfc cstring int64


    【解决方案1】:

    %lld%I64d 也同样有效。

    strCode.Format(_T("Code = %lld, Result = %I64d \n"),lCode,lResult);
    

    【讨论】:

      【解决方案2】:

      我认为你需要试试这个:

      __int64 val;
      ......
      ParamVal.Format( _T("%d{I64}"), val);
      

      【讨论】:

        【解决方案3】:

        我没有方便的 windows 机器来测试这个,但我认为 CString 应该接受这个:

        querySQLStr.Format("%I64d", dirID);
        

        可能值得注意的是,这是特定于 Windows 的,但由于您使用的是 CString,我想这没关系。

        【讨论】:

        • 我可以确认它确实有效。 %lld(两个小写的 L)也可以使用,'ll' 指的是 LONGLONG,它(至少在 Win32 下)被定义为 _int64,INT64(由不同的头文件定义)也是如此。
        猜你喜欢
        • 2013-12-09
        • 2011-11-21
        • 1970-01-01
        • 2020-12-01
        • 1970-01-01
        • 2023-04-01
        • 2011-11-23
        • 2012-03-07
        • 2011-07-29
        相关资源
        最近更新 更多