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
Implementing strstr
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="blmblm, post: 4050480"] Depends where the fallthrough occurs, no? switch (i) { case 0: case 1: printf("%d is 0 or 1\n", i); break; case 2: case 3: printf("%d is 2 or 3\n", i); break; default: printf("%d is not in 0..3\n", i); } can be recoded as if ((i == 0) || (i == 1)) { printf("%d is 0 or 1\n", i); } else if ((i == 2) || (i == 3)) { printf("%d is 2 or 3\n", i); } else { printf("%d is not in 0..3\n", i); } and in fact the "switch" version is, as far as I know, a fairly standard idiom -- as I think Seebs pointed out. (Aside to Seebs: I was going to include /* FALLTHROUGH */ comments but realized I wasn't sure where they should go. ? ) [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
Implementing strstr
Top