How to write INT64 to CString
Asked Answered
T

3

5

I am coding in 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

Timi answered 18/6, 2010 at 8:19 Comment(0)
G
8

I don't have a windows machine handy to test this on, but I think CString should accept this:

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.

Guide answered 18/6, 2010 at 8:29 Comment(1)
I can confirm it does work. %lld (two lowercase Ls) will also work, the 'll' referring to LONGLONG, which (under Win32 at least) is typedefed as _int64, as is INT64 (defined by different header files).Aleurone
B
0

i think you need to try this:

__int64 val;
......
ParamVal.Format( _T("%d{I64}"), val);
Brundisium answered 15/3, 2015 at 14:13 Comment(0)
G
0

%lld and %I64d both work equally as well.

strCode.Format(_T("Code = %lld, Result = %I64d \n"),lCode,lResult);
Geraldgeralda answered 17/1, 2020 at 19:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.