Thread: Does switch case only accept integer value ?

  1. #1
    Registered User
    Join Date
    Oct 2022

    Does switch case only accept integer value ?

    Ignore switch case accept integer and character value

    solved problem myself
    Last edited by Kittu20; 01-01-2023 at 01:59 AM. Reason: solved myself

  2. #2
    Registered User
    Join Date
    Sep 2022
    For anyone else reading this, switch-case is restricted to integers by the C standard. Some types are implicitly casted to an integer, like bool (_Bool) and char. Be careful whenever you use char values. There's no ambiguity in the range of ASCII characters. However, keep in mind that the signedness of char is dependent on the implementation, that char literals are of type int as per C standard, and that the encoding of your code may represent glyphs outside of the ASCII range with more than one value (e.g. UTF-8).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with switch case messing up case variables
    By mp59 in forum C Programming
    Replies: 3
    Last Post: 07-02-2018, 12:12 PM
  2. Replies: 0
    Last Post: 03-09-2016, 03:58 PM
  3. Replies: 11
    Last Post: 08-25-2008, 12:01 PM
  4. switch case
    By lilhawk2892 in forum C++ Programming
    Replies: 18
    Last Post: 09-21-2005, 08:23 PM
  5. Case and switch
    By CAP in forum C Programming
    Replies: 5
    Last Post: 07-13-2002, 03:16 PM

Tags for this Thread