O'Reilly logo

Windows® via C/C++, Fifth Edition by Christophe Nasarre, Jeffrey Richter

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required