devxlogo

Tip Bank

Boolean Conversion

Numeric values and pointers are implicitly converted to a Boolean value in conditional expressions. For example: void *p = get_ptr();if(p){ // process p} A zero value evaluates as false. All

Notes about the system() Function

The system() function (declared in ) launches another program from the current program. As opposed to what most users think, it doesn’t return the exit code of the launched process.

Using Pointers as Integers

In the early days of C, pointers were plain integers. Relics of this approach can still be found in vintage APIs and legacy code. For instance, the ANSI C header

A Recommended Exception Handling Policy

Exceptions report abnormal runtime situations. Although you have other mechanisms for detecting and reporting runtime errors, exceptions are advantageous because they automate the process of passing the error from a

Uses of the

The volatile specifier disables various optimizations that a compiler might automatically apply and thus introduce bugs. I

Create a Touch utility

The SetCreationTime, SetLastWriteTime, and SetLastAccessTime methods of the System.IO.Directory class let you modify the date attributes of a file or directory: ‘ Change the access date- and time of all

The std::unexpected() Function

The Standard Library defines a function called std::unexpected() which is invoked when a function throws an exception not listed in its exception specification. std::unexpected invokes a user-defined function that was