devxlogo

February 2, 2001

A Beginner’s Checklist

Beginners and even experienced programmers who switch to a new compiler suddenly discover that their programs don’t compile anymore. Sometimes the programs compile but produce numerous warning messages. In most

MS Default Pointer Value

Don’t forget that MS compiler initiates pointers with 0xCCCCCCCC value. In this case: void *p; … //do something here… if (p!=NULL) delete p; // Memory violation The right way void*

Different Uses For Sizeof Operator

Sizeof is a useful operator because it reports both the amount of memory that data items take and the number of bytes that data types. For instance: cout

I/O Formatting With Stringstream

The sprintf() function isn’t type-safe, it doesn’t support user-defined types and it’s a common source of buffer overflow bugs. In C++, there’s a better alternative to sprintf(), namely stringstream objects.

Extract the Extension of a Filename

Extracting the extension of a filename is a requirement in many file searches and file I/O related applications. A simple way to do this is to use the split function.