
December 7th, 2012, 08:24 PM
|
|
Registered User
|
|
Join Date: Oct 2012
Posts: 5
Time spent in forums: 51 m 10 sec
Reputation Power: 0
|
|
|
Error: case label.. Not sure what GCC means.
I am getting this error running a simple code;
Code:
fig04_07.c: In function ‘main’:
fig04_07.c:35:13: error: case label does not reduce to an integer constant
fig04_07.c:38:13: error: case label does not reduce to an integer constant
fig04_07.c:41:13: error: case label does not reduce to an integer constant
fig04_07.c:44:13: error: case label does not reduce to an integer constant
fig04_07.c:47:13: error: case label does not reduce to an integer constant
fig04_07.c:50:13: error: case label does not reduce to an integer constant
fig04_07.c:51:13: error: case label does not reduce to an integer constant
Code:
#include <stdio.h>
int main(void){
int grade;
int aCount = 0;
int bCount = 0;
int cCount = 0;
int dCount = 0;
int fCount = 0;
printf("Enter the letter grades\n");
printf("Enter the OEF characterto end the input\n");
while ((grade = getchar()) != EOF){
if (grade <= 90) { grade -= 32; }
switch (grade) {
case "A":
++aCount;
break;
case "B":
++bCount;
break;
case "C":
++cCount;
break;
case "D":
++dCount;
break;
case "F":
++fCount;
break;
case "\n":
case "\t":
case ' ':
break;
default:
printf("Incorrect letter grade entered!\n");
printf("Enter a new grade\n");
break;
}
}
return 0;
}
I wonder, I added the if statement just to lower the letter (making it easier to check), though this simple example was taken from a book (C: How to program 7th edition) I wonder what's wrong?
Note that the code is modified.
|