Thread: Error messages

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    17
    Rep Power
    0

    Error messages


    I have two error messages in the code below that I have no idea what they mean. Knot knowing what they mean means that I am unable to fix them.

    The errors are

    error: switch quantity not an integer
    error case label does not reduce to an integer constant

    #include <stdio.h>

    int main(int argc, char *argv[])
    {
    float inputamount, result;

    printf("\n\n Enter amount to be converted");
    printf("\n in the form SA, where the");
    printf("\n where the two letters represent");
    printf("\n a country.");
    printf("\n ad = Australian dollars.");
    printf("\n gb = British Pounds.");
    printf("\n jp = Japenes yen.");
    printf("\n vd= Vitnames dollars.");
    printf("\n\n Enter amount to convert: ");

    switch(inputamount)
    {

    case "ad":
    result = inputamount * 1.044;
    break;

    case "gb":
    result = inputamount / 0.63;
    break;

    case "jp":
    result = inputamount * 95.057;

    case "vd":
    result = inputamount * 2.106;

    break;

    default:
  2. #2
  3. No Profile Picture
    I haz teh codez!
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2003
    Posts
    2,556
    Rep Power
    2338
    That's what happens when you copy/paste bad code from a likely spammer. Try learning the language instead of copy/paste.

    Switches can only be run on integers, just as the error says. The switch cases must also be integers, again as the error says.
    I ♥ ManiacDan & requinix

    This is a sig, and not necessarily a comment on the OP:
    Please don't be a help vampire!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    17
    Rep Power
    0
    [QUOTE=ptr2void]That's what happens when you copy/paste bad code from a likely spammer. Try learning the language instead of copy/paste.

    Switches can only be run on integers, just as the error says. The switch cases must also be integers, again as the error says.[/QUOT


    thanks I did copy and paste that's how I learn then I break it down and learn and then I ask the questions I cant solve. thanks for the help
  6. #4
  7. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,417
    Rep Power
    1871
    > thanks I did copy and paste that's how I learn then I break it down and learn and then I ask the questions I cant solve. thanks for the help
    You can spend your life working in a scrapyard pulling cars apart, but you'll never be an automotive engineer until you actually start putting them together from scratch.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    17
    Rep Power
    0
    Originally Posted by salem
    > thanks I did copy and paste that's how I learn then I break it down and learn and then I ask the questions I cant solve. thanks for the help
    You can spend your life working in a scrapyard pulling cars apart, but you'll never be an automotive engineer until you actually start putting them together from scratch.
    very very true

IMN logo majestic logo threadwatch logo seochat tools logo