Click here to Skip to main content
12,820,233 members (23,439 online)
Click here to Skip to main content

Stats

204K views
347 downloads
140 bookmarked
Posted 9 Aug 2010

Something You May Not Know About the Switch Statement in C/C++

, 19 Dec 2012 CPOL
A discussion on how switch/case is executed, by reverse engineering in VC++
#include "functions.h"

int main7()
{
    int i =15;

    switch (i)
    {
        case 2: f2(); break;
        case 1: f1(); break;
        case 5: f1(); break;
        case 10: f1(); break;
        case 7: f2(); break;
        default: f3(); break;
        case -3: f2(); break;
        case 12: f1(); break;
        case 17: f2(); break;
        case 18: f1(); break;
    }

    return 0;
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Zuoliu Ding
Software Developer
United States United States

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170308.1 | Last Updated 19 Dec 2012
Article Copyright 2010 by Zuoliu Ding
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid