Case Statement

This is a discussion on Case Statement within the C Programming forums, part of the General Programming Boards category; Note to OP: investigate your compiler's assembly output of a switch statement with and without "holes" for cases; let us ...

  1. #16
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Note to OP: investigate your compiler's assembly output of a switch statement with and without "holes" for cases; let us know if it effectively creates an if-else tree. This will help find a solution if we know more of the limitations.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  2. #17
    Registered User
    Join Date
    Aug 2008
    Location
    Delaware
    Posts
    32
    The switch statement does a compare and branch to each Case defined. It ignores holes and only generates branches to valid Cases.

    It's a Jump Table not an If..else. It executes much faster than an if..else.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 03-05-2009, 10:32 AM
  2. switch case statement
    By stanlvw in forum C++ Programming
    Replies: 3
    Last Post: 02-26-2008, 04:06 AM
  3. Intel syntax on MinGW ?
    By TmX in forum Tech Board
    Replies: 2
    Last Post: 01-06-2007, 08:44 AM
  4. char copy
    By variable in forum C Programming
    Replies: 8
    Last Post: 02-06-2005, 09:18 PM
  5. Strings and Switch Statement
    By Ajsan in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2004, 01:16 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21