What is “…” in switch-case in C code

前端 未结 4 1072
慢半拍i
慢半拍i 2020-11-29 05:33

Here is a piece of code in /usr/src/linux-3.10.10-1-ARCH/include/linux/printk.h:

static inline int printk_get_level(const char *buffer)
{
  if (         


        
4条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-29 06:15

    case '0'...'7': is case ranges Speciacation in gcc.

    Range specification for case statement.

    Write spaces around the ..., for otherwise it may be parsed wrong when you use it with integer values

    case '0' or case '1' or case '3' and so on case '7':
    or case 'b' :
    just return buffer[1]; 
    

提交回复
热议问题