Actually I dot this from MSDN and it gives only a compile error that, addition ) at the end.
But it's clearly written in MSDN that this will cause unpredictable results. In fact given as a warning to avoid such code!
The call will fail if the stringobject itself is offered as a
parameter to Format. For example, the following code:
CString str = "Some Data";
str.Format("%s%d", str, 123); // <code>Attention: str is also used in the parameter list.</code>
will cause unpredictable results.
Also note this...
When you pass a character stringas an optional argument, you must
cast it explicitly as LPCTSTR.
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
It just always confused me why people tend to shun good advice. I am always laughed at for being cautious since it tends to yield the same results as being reckless 9 times out of 10. I sometimes question whether I should just join in and throw caution to the wind, but that's just not me so I continue mind the documentation and take the safer road.
CString::Format() is based on sprintf() which is based on printf().
TCHAR strBuffer[ 255 ]; // you can tweak this down to what ever size you need, or use a pointer
_stprintf( strBuffer, _T("%s%d"), _T("Some Data: "), 123 );
// or you can be safe and use
_sntprintf( strBuffer, 255, _T("%s%d"), _T("Some Data: "), 123 );
I didn't understand the explanation of that warning when I started to use the function as the OP.
Luckily I had no crash so far :P
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
Rating helpfull answers is nice, but saying thanks can be even nicer.
Hey all, was hoping you could help me with a little info here.
There's this application we use that's around 10+ years old, and I'm pretty sure it was written in C++.
There are some data files it uses with an extension of ".md" and a fileheader of "MDB2"
I was wondering if anyone's come across a database or file type like this in the past. My reasoning is, the source for the app has been lost for some time, but that's ok, the app itself runs decent enough, but we'd really like to update the data in these files if possible.
The powers that be are hoping it's a known format, but I've tried just about everything I could think of to access them.
Does anybody knows why VC6.0 decided to give me this error message everytime I set breakpoint?
I am about to go thru "standard VC6.0 recovery" - delete /debug , *.clw,
*.aps. Hope it works!
I don't think this was my case. I have been compiling and debugging just fine when it just started happening.
Then it went away! I suspect it may have something to do with running a timer because it give me this error when I was setting the breakpoints in OnTimer function / method. It started working again, but I had other problems when keeping the timer running during debugging so I immediately killed it in OnTimer. When I have a break I’ll try to make it happen again.
Thanks for you help.
NM is for Notification Messages sent from Window controls to their parent window, where as WM are Windows Messages.
thats the classic difference
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
You can try computing HD5 hash of 4-5 files in the CD and also store their path. Then everytime a CD is inserted you check if files you checked last time are present on CD and if their MD5 hases are identical. You may also compute a single unique number by combining file names and file data information. So that comparison is easy.