I was looking at some code in the linux kernel, and I came across expressions like case '0' ... '9':
To try this, I created a test program below.
#include <iostream> int main() { const int k = 15; switch (k) { case 0 ... 10: std::cout << "k is less than 10" << std::endl; break; case 11 ... 100: std::cout << "k is between 11 and 100" << std::endl; break; default: std::cout << "k greater than 100" << std::endl; break; } }
The program described above compiles, although I had never encountered elipses in the case constructor before. Is this standard C and C ++ or is it a GNU extension for the language?
c ++ c
doron May 7, '11 at 23:28 2011-05-07 23:28
source share