C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 7th, 2012, 08:24 PM
Ephexeve Ephexeve is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 5 Ephexeve User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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.

Reply With Quote
  #2  
Old December 7th, 2012, 08:45 PM
Ephexeve Ephexeve is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 5 Ephexeve User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 51 m 10 sec
Reputation Power: 0
Fixed! Forgot C has differences between " and '
Comments on this post
dwise1_aol agrees: Bingo!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Error: case label.. Not sure what GCC means.

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap