I’m trying to make a 2-player chess game for the terminal. As far as I know ‘switch’ statements are faster than ‘if/else’, so I’m trying to use it more often. The chess board is basically a 2d array with char’s which are pieces on the board ( letters K/Q/R/B/N/P ).
It just so happened that I need to compare element from that array to a char. With ‘if’ statement it works, with ‘switch’ it doesn’t. If it won’t work that way I’ll just use ‘if’ statements, it’s not a big deal, but I’m just curious why it doesn’t work with ‘switch’. All the code is too big to send it all, but here’s an example of what I tried to do: