I want to give a variable a value according to the value of a char within a string.
For example, if (in[12] == z) y = 8;
So what I've done is assign some const chars, and I'm using a switch... case to assign the values. I keep getting 'duplicate case value' errors from the line with "case (V): y = 5; break;" onwards, and my compiler tells me that the case value was previously used in the previous line.
What am I doing wrong?
Yes, it's a roman numeral calculatorCode://... const char I = ('i'||'I'); const char V = ('v'||'V'); const char X = ('x'||'X'); const char L = ('l'||'L'); const char C = ('c'||'C'); const char M = ('m'||'M'); const char operators = ('/'||'*'||'+'||'-'); //... for (i = 0, x = 0; i < 256, in[i] != '\0'; i++) { if (in[i] != operators) { switch (in[i]) { case (I): y = 1; break; case (V): y = 5; break; case (X): y = 10; break; case (L): y = 50; break; case (C): y = 100; break; case (M): y = 1000; break; default: cout<<"Oh ......... Something's gone wrong."; break;} /* code to do something with y before the cycle starts again and it's changed */ }.



LinkBack URL
About LinkBacks
. 


