I am trying to create a simple string switch statement. Now, I know that you can use different variable types for the switch statement, but I keep getting an error that says "switch quanity is not an integer". Isnt it possible to have a "string" switch statement?
Here is the switch:
Code:
string translate( string reg )
{
switch (reg)
{
case "$t0" : return "01000";
case "$t1" : return "01001";
case "$t2" : return "01010";
case "$t3" : return "01011";
case "$t4" : return "01100";
case "$t5" : return "01101";
case "$t6" : return "01110";
case "$t7" : return "01111";
case "$t8" : return "10000";
case "$t9" : return "10001";
case "$a0" : return "00100";
case "$a1" : return "00101";
case "$a2" : return "00110";
case "$a3" : return "00111";
case "$v0" : return "00010";
case "$v1" : return "00011";
default: return reg;
}
}