Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8666223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:40:28+00:00 2026-06-12T17:40:28+00:00

I am working on a game and I ran my code and got the

  • 0

I am working on a game and I ran my code and got the error “case label does not reduce to an integer constant.” I think I know what this means, but how do I fix it? Here is my code:

#include<stdio.h>
#include<stdlib.h

int player_cash[3] = {50};
char job[][20] {
    'A',
    'B',
    'C',
    "Donate",
    "Go to work",
    "Exit"
};
int jobs;

int main()
{
    while(player_cash[0] > 0) {
        printf("Please type A, B, C, Donate, Go to work, or Exit\n");
        switch(jobs) {

            case 'A':
            player_cash[0]-=5;
            player_cash[1]+=5;
            printf("Cash=%i\n\n", player_cash[0]);
            continue;

            case 'B':
            player_cash[0]-=5;
            player_cash[2]+=5;
            printf("Cash=%i\n\n", player_cash[0]);
            continue;

            case 'C':
            player_cash[0]-=5;
            player_cash[3]+=5;
            printf("Cash=%i\n\n", player_cash[0]);
            continue;

            case "Donate":
            player_cash[0]-=15; //Error here
            player_cash[1]+=5;
            player_cash[2]+=5;
            player_cash[3]+=5;
            printf("Cash donated\n\n");
            printf("Cash=%i\n\n", player_cash[0]);
            continue;

            case "Go to work":
            player_cash[0]+=10; //Error here
            printf("Work done\n\n");
            printf("Cash=%i\n\n", player_cash[0]);
            continue;

            case "Exit":
            printf("Thanks for playing!\n\n"); //Error here
            break;

            default:
            printf("Does not compute");
            continue;
        }
    }
        getchar();
        return 0;
}

So, what I want the user to do is type in one of the options, and do the action that corresponds with it. How do I fix this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T17:40:29+00:00Added an answer on June 12, 2026 at 5:40 pm

    Some of your case labels are characters (type char, indicated with 's). Those are integer constants.

    Other labels are string literals (indicated with ") which have an effective type of const char *.1 Those are not integer constants and can not be used in this way.


    1 For historical reasons they can often be used as if they were char *, but don’t try to change them. Or else.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, so I have this partially working game, I know the solutions should be
So my game was working fine but the sprite would not handle repeated key
I'm working on a large Monopoly game as a project in school and ran
Alright, so I'm currently working on a game and ran into a memory issue
As im working on a game engine for my company. i got in the
I'm currently working on a game based on Slick2D, but I ran into a
Working on game where plates will be falling from top to bottom. Some plates
I am working on game application and i use AnimationDrawable for image change. but
I've been trying to get this Sudoku game working, and I am still failing
Im working on a game, and ive seen a lot of memory consuption, im

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.