Thread: Really need some help

  1. #1
    Registered User
    Join Date
    Feb 2012
    Posts
    16

    Really need some help

    trying to figure out why i am getting error "error expected ';' before ':' ." it is referencing my switch statement, case 1 line 15 any ideas?
    Code:
    /*Calvin Moss  CSCI 112
    */
    
    
    #include <stdio.h>
    #include "proto.h"
    int main(void)
    {
        int choices;
        choices = getProblem();
    do
    {
            switch(choices)
        {
            1:
            {
                int milliliterPerHour;
                int dropRateFactor;
                int dropsPerMin;
                dropRateFactor(milliliterPerHour, dropRateFactor);
                dropsPerMin = dropsMin(milliliterPerHour, dropRateFactor);
                printf("The drop rate per minute is %d.\n", dropsPerMin);
                break;
            }
            2:
            {
                int hours;
                int millilitersPerHour;
                printf("Problem=> 2");
                printf("Enter number of hours=> \n");
                scanf(%d, &hours);
                millilitersPerHour = mlPerHour(hours);
                printf("The rate in milliliters per hour %d\n", millilitersPerHour);
                break;
            }
            3:
            {
                float mkh;
                int kg;
                int concentration;
                int millilitersPerHours;
                kgRate(mkh,kg,concentration);
                millilitersPerHours = weight(mkh,kg,concentration);
                printf("The rate in milliliters per hour %d\n", millilitersPerHours);
                break;
            }
            4:
            {
            
                int rateUnits;
                int concentrationUnits;
                int millilitersPersHour;
                getUnits(int rateUnits, int concentrationUnits);
                millilitersPersHour = units(int rateUnits, int concentrationUnits);
                printf("The rate in milliliters per hour %d\n", millilitersPersHour);
                break;
            }
            5:
            {
                printf("Exit has been Chosen, now closing\n");
                break;
            }
            default: printf("Unexpected input parameter. Please, behave or I am going to have a talk with your Mama!\n");
                break;
        }
    } while (choices != 5);
    }

  2. #2
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    You are missing the case keyword: "case 1:"

    Jim

  3. #3
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,738
    You need the keyword "case" in front of everyone of your cases.
    Devoted my life to programming...

  4. #4
    Registered User
    Join Date
    Feb 2012
    Posts
    16
    Awesome that fixed it, got more errors first compile attempt but you rock!@

    *edit* while you guys are looking , anyone know the easiest way to reference a method in a different c file, example i have a file get_problem.c and in it the method is (dropRateFactor) in case one, and it is erroring saying no such function.

    **Edit to my edit** figured it out, it was because i had a variable named the same thanks!
    Last edited by Zocheyado; 02-27-2012 at 11:57 PM.

  5. #5
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    If you have this much code before you tried to compile, you are not compiling often enough. The more often you compile the fewer errors you will need to locate and fix, with the added bonus that you will have fewer lines to search for the errors. Compile early, compile often. Don't be afraid to compile after you enter just a couple of lines of code.

    Jim

Popular pages Recent additions subscribe to a feed