windows 如何将 INT64 写入 CString
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3068088/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to write INT64 to CString
提问by sxingfeng
I am coding in c++ windows.
我在 c++ windows 中编码。
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;
is it right to use %64d? Many Thanks
使用 %64d 合适吗? 非常感谢
回答by ryan_s
I don't have a windows machine handy to test this on, but I think CString should accept this:
我没有方便的 Windows 机器来测试这个,但我认为 CString 应该接受这个:
querySQLStr.Format("%I64d", dirID);
It's probably worth noting that this is windows specific, but since you're using CString I guess that's okay.
可能值得注意的是,这是特定于 Windows 的,但由于您使用的是 CString,我想这没问题。
回答by mazen
i think you need to try this:
我认为你需要试试这个:
__int64 val;
......
ParamVal.Format( _T("%d{I64}"), val);
回答by BlueMax
%lldand %I64dboth work equally as well.
%lld和%I64d也同样有效。
strCode.Format(_T("Code = %lld, Result = %I64d \n"),lCode,lResult);