Case and or C++

Hi guys

I have a question; Can I use case argument with an or parameter? Example.
1
2
3
switch(lol) {
case "a" || "A" { /* do something */ }
} 


Because I try but when it compile it says:

main.cpp: 33:2: error: previously used here
main.cpp: 35:2: error: duplicate case value
main.cpp: 33:2: error: previously used here
main.cpp: 36:2: error: duplicate case value
main.cpp: 33:2: error: previously used here
main.cpp: 37:2: error: duplicate case value
main.cpp: 33:2: error: previously used here
main.cpp: 38:2: error: duplicate case value
main.cpp: 33:2: error: previously used here
main.cpp: 39:2: error: duplicate case value
main.cpp: 33:2: error: previously used here
main.cpp: 40:2: error: duplicate case value
main.cpp: 33:2: error: previously used here
main.cpp: 41:2: error: duplicate case value
main.cpp: 33:2: error: previously used here
ETC.


Regards :D
You would do:

1
2
3
4
5
6
7
8
switch (lol)
{
   case 'a':
   case 'A':
      // do stuff
      break;

}
- Or you could use the "toupper" or "tolower" functions.
+1 to thejman's solution:

1
2
3
4
5
6
switch( tolower( lol ) )
{
  case 'a':
    // do stuff
    break;
}
Yeah nice one, thx all :D Sloved
Topic archived. No new replies allowed.