About 218,000 results
Open links in new tab
  1. How can I compare strings in C using a `switch` statement?

    In C there is a switch construct which enables one to execute different conditional branches of code based on an test integer value, e.g., int a; /* Read the value of "a" from some …

  2. Syntax of switch statement in C? - Stack Overflow

    I am trying to understand the switch statement in C (I am using gcc from Ubuntu v16.04). I am able to understand its semantics, but have the following 2 questions about its syntax: I have …

  3. Larger than and less than in C switch statement

    A compiler should deal with if/else construct just as efficiently as a switch (even if you weren't dealing with ranges). Switch can't handle ranges as you have shown, but you could find a way …

  4. c - Switch statement with returns -- code correctness - Stack …

    Jun 18, 2010 · On the other hand, if the case-clause is more complex, or something happens after the switch-statement, I wouldn't recommend using return in it, but rather set a variable in the …

  5. c - Is 'switch' faster than 'if'? - Stack Overflow

    Is a switch statement actually faster than an if statement? I ran the code below on Visual Studio 2010's x64 C++ compiler with the /Ox flag: #include <stdlib.h> #include <stdio.h> #incl...

  6. c - How to write switch statement with "or" logic? - Stack Overflow

    Mar 10, 2013 · Below, I have created a simple switch statement that works fine. I was wondering how I could change this code so it is switch(c), then case 1, case 2, case 3, default. Example: …

  7. c - Use switch with number case and char case - Stack Overflow

    Nov 18, 2016 · Others have suggested using %c so that your not mixing characters with integers but you need to be careful with the rest of the code. You may need a cast for the switch …

  8. Inline switch / case statement in C# - Stack Overflow

    Inline switch / case statement in C# Asked 15 years, 2 months ago Modified 2 years, 9 months ago Viewed 98k times

  9. c - How does switch statement work? - Stack Overflow

    Feb 23, 2012 · How are statements that come before any case labelled statement in a switch-case block treated. Please explain the behavior of the following programs prog1: …

  10. C - Switch with multiple case numbers - Stack Overflow

    So my professor asked us to create a switch statement. We are allowed to use only the "SWITCH" statement to do the program. He wants us to input a number and then display it if it …