I wanted to use a switch statement to select from several choices and print the choice.
The problem I am having is that it does not reconize the case statements the way I would assume they should:
Intel based, xp pro, borland 4.5
I get an error message saying that the two statements following the first case are duplicates.
I have also tried to separte them out into individual statements:
This seemed to work... When it encountered the 'R' it work fine skipping 'r' and printing as you would expect. When it encounter the 'r' first it would print and then print a second time because it would see the 'R'. Very strange.
Any insight would be great...
The problem I am having is that it does not reconize the case statements the way I would assume they should:
Intel based, xp pro, borland 4.5
Code:
switch (gasType)
{
case (('r') || ('R')): printf("Type of gasoline: %s\n",RArray);
case (('u') || ('U')): printf("Type of gasoline: %s\n",UArray);
case (('s') || ('S')): printf("Type of gasoline: %s\n",SArray);
}
I have also tried to separte them out into individual statements:
Code:
switch (gasType)
{
case 'r' : printf("Type of gasoline: %s\n",RArray);
case 'R' : printf("Type of gasoline: %s\n",RArray);
}
Any insight would be great...
Comment