Switch statement / default:

This is a discussion on Switch statement / default: within the C Programming forums, part of the General Programming Boards category; I know that the "default:" is optional in a switch statement, and if not a part of the switch statement ...

  1. #1
    Registered User
    Join Date
    Jan 2007
    Location
    Euless, TX
    Posts
    144

    Switch statement / default:

    I know that the "default:" is optional in a switch statement, and if not a part of the switch statement and no values match any case statements, there would be no action. If, however, a default is included and there is no action to take under the default, and a value that had no case statement for that value, and was therefore passed down to the default, could there be any action that may cause faults to the program being executed?

    Thanks.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,274
    What do you mean by "cause faults to the program being executed"?
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Jan 2007
    Location
    Euless, TX
    Posts
    144
    Could there be a possibility of the program crashing, for example?

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,274
    No, except due to some other problem.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User
    Join Date
    Jan 2007
    Location
    Euless, TX
    Posts
    144
    I didn't think so, but wanted another opinion of a real expert.

    Thanks LL

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Stack operations from switch statement elements
    By mlsrar in forum C Programming
    Replies: 15
    Last Post: 10-02-2008, 02:12 PM
  2. switch statement
    By guillermoh in forum C Programming
    Replies: 5
    Last Post: 03-10-2008, 03:17 PM
  3. Switch statement problem
    By jalex39 in forum C Programming
    Replies: 6
    Last Post: 03-08-2008, 04:05 PM
  4. Switch Statement
    By DarkDot in forum C++ Programming
    Replies: 11
    Last Post: 03-28-2007, 11:11 PM
  5. Efficiency with the switch() statement...
    By Unregistered in forum C++ Programming
    Replies: 3
    Last Post: 10-14-2001, 03:47 PM

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