I have a switch...
In case 1 and 2 the multidimensional array of string works fine
But when it do the case 3, the string value in stringWeight[1] was erased.
BTW, the stringWeight[1] value for case 3 is the same as the value in stringWeight[1] in case 2.
Basically, I have a for loop that counts, from 1 to 3.
It will do first case 1, then case 2, then case 3.
For case 1 it will store a value to stringWeight[0]
case 2 will store a value to stringWeight[1] with same value for stringWeight[0] from case 1
case 3 will store a value to stringWeight[2], with stringWeight[0] from case 1 and stringWeight[1] from case 2
I can store the value to another string like
string2 = stringWeight[1];
but I what I want is the explanation why stringWeight[1] has no value at case 3.
EDIT:
Now if I add case 4, the stringWeight[1] will now have a value but stringWeight[2] has no value. :(
Here is my code...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
switch(count)
{
case 1:
sprintf (display, "Weights:\n%s", stringWeight[0]);
//actually I can do this
//string1 = stringWeight[0];
CreateInstructionsWindow (display, "Please load second weight");
break;
case 2:
//sprintf (display, "Weights:\n%s \n%s", string1, stringWeight[1]);
sprintf (display, "Weights:\n%s \n%s", stringWeight[0], stringWeight[1]);
//string2 = stringWeight[1];
CreateInstructionsWindow (display, "Please load third weight");
break;
case 3:
//sprintf (display, "Weights:\n%s \n%s \n%s", string1, string2, stringWeight[2]);
sprintf (display, "Weights:\n%s \n%s \n%s", stringWeight[0], stringWeight[1], stringWeight[2]);
CreateInstructionsWindow (display, "All weights obtained.");
break;
}
| |
Thanks for the help in advance