The Summation Sample Application

The Summation (16-Summation.exe) sample application shown later in this chapter demonstrates how to use exception filters and exception handlers to recover gracefully from a stack overflow. The source code and resource files for the application are in the 16-Summation directory on the companion content Web page. You might want to review the chapters on SEH to fully understand how this application works.

The Summation application sums all the numbers from 0 through x, where x is a number entered by the user. Of course, the simplest way to do this is to create a function called Sum that simply performs the following calculation:

Sum = (x * (x + 1)) / 2;

However, for this sample, I have written the Sum function to be ...

Get Windows® via C/C++, Fifth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.