October 12, 2008

How to raise an user break exception (int 3) dynamically in my code?

The embedded assembly code way:
_asm int 3

The Windows API way:

After raised an user break exception in your code, the program can be attached to a debugger. For some situation, this is a good way to debug your buggy problem.

Reference in MSDN:

October 04, 2008

How to convert STL string / wstring to upper / lower case?

This is the STL algorithm way, I think it is better than the itoa() way.

Sample Code:

#include <cctype>
#include <string>

#include <algorithm>

using namespace std;

// Convert string to lower case
string strTest = "I am a STL string";
  strTest.begin(), strTest.end(),
  tolower); // toupper for upper case

// Convert wstring to upper case
wstring wstrTest = L"I am a STL wstring";
  wstrTest.begin(), wstrTest.end(),
  towupper); // towlower for lower case

Reference in MSDN: