Every once in a while I found some C/C++ tips and tricks. This page is going to be the repository of those tips and tricks.

Print the first n characters with printf()
const char* pStr = "C Tips and Tricks.";
printf( "%.*s\n", 5, pStr);  // This will print "C Tips"

Specifying enum type
enum EnumAsByte : unsigned char { ... };
enum EnumAsUnsignedShort : unsigned short { ... };