Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
which is better "switch" or "if-else"
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Keith Thompson, post: 2414262"] A jump table used (by the compiler) to implement a switch statement is likely to be more efficient than an explicit one using function pointers. A compiler-generated jump table will be a table of code addresses (labels), not function pointers, avoiding the overhead of a function call and return. There's no good way to implement an array of labels in C. <OT>gcc has an extension that lets you store the value of a label in a pointer, and use the pointer as the target of a goto; this is, of course, non-portable.</OT> [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
which is better "switch" or "if-else"
Top