-
September 13th, 2017, 09:46 AM
#1
String Format Crash
I have question on string formatting.
It will crash at the line strCombine.Format("%ld000%s", a, "+0800"); when running on Microsoft visual studio 2010 but not in visual studio 2003 by using the exact same code.
Any idea why?
Code Snippet:
Code:
CString strCombine="";
time_t a = 150519836000;
strCombine.Format("%ld000%s", a, "+0800"); //crash at this line at VS2010 but not at VS2003
However if change to code as below, it will not crash at VS2010 anymore. Just curious why?
Code:
CString strCombine="";
time_t a = 150519836000;
strCombine.Format("%ld000", a); //after changing this line, it no longer crash anymore
strCombine= strCombine + "+0800";
-
September 13th, 2017, 12:18 PM
#2
Re: String Format Crash
Originally Posted by PHChang
I have question on string formatting.
It will crash at the line strCombine.Format("%ld000%s", a, "+0800"); when running on Microsoft visual studio 2010 but not in visual studio 2003 by using the exact same code.
Any idea why?
Code Snippet:
Code:
CString strCombine="";
time_t a = 150519836000;
strCombine.Format("%ld000%s", a, "+0800"); //crash at this line at VS2010 but not at VS2003
However if change to code as below, it will not crash at VS2010 anymore. Just curious why?
Code:
CString strCombine="";
time_t a = 150519836000;
strCombine.Format("%ld000", a); //after changing this line, it no longer crash anymore
strCombine= strCombine + "+0800";
Using lld instead of ld in your format string fixes it. I'm not sure what changed between versions though.
-
September 13th, 2017, 08:38 PM
#3
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|