0

Does switch work with arrays?

23rd Apr 2018, 8:40 AM
Keevod
Keevod - avatar
6 Respuestas
+ 6
I don't know
23rd Apr 2018, 11:02 AM
Hackerman
Hackerman - avatar
+ 2
Then it's not the array type you have to use in switch, but a simple int. In your idea using array makes no sense. Just assign user's input to int variable and use it.
23rd Apr 2018, 9:35 AM
Sergey Semendyaev
Sergey Semendyaev - avatar
+ 1
How do you want to use it? for (x=0; x<sizeof(array); x++){ switch(array[x]){ case 'something': //who knows } } Like this? Note: Never used array like this... don't know if it will work. But it should... kinda..
23rd Apr 2018, 8:47 AM
Akib
Akib - avatar
0
I don't think so.
23rd Apr 2018, 9:05 AM
Sergey Semendyaev
Sergey Semendyaev - avatar
0
I would like to specify an array x, and in switch to parse some values ​​of the array, for example, if the user entered 3, and 3 is in the array, then the case line with 3 would be executed. Many problems, but it's interesting!
23rd Apr 2018, 9:30 AM
Keevod
Keevod - avatar
0
Oh, I understand. With sleep brain issued this strange idea. Sorry me and thank you for explanation!
23rd Apr 2018, 10:00 AM
Keevod
Keevod - avatar