scanf for char input getting skipped

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • FerrisUML

    #1

    scanf for char input getting skipped

    Hello eveyone! Im working on the following program for an intro to C
    class and I seem to be having a problem with the last scanf statement,
    scanf("%c", &quitVal). Seems that its getting skipped and the program
    simply exits. Is there something that im not seeing? Thanks if
    advance.

    int main()
    {

    int clock_number = 0;
    float hours_worked = 0;
    float hourly_rate = 0;
    float total = 0;
    char quitVal;

    goto start;

    start:

    printf("Please enter the employee's clock number:\n");
    scanf("%i", &clock_numbe r);
    printf("Please enter the employee's hourly rate:\n");
    scanf("%f", &hourly_rate );
    printf("Please enter the hours worked:\n");
    scanf("%f", &hours_worke d);
    total = hourly_rate * hours_worked;
    printf("Employe e Clock Number\tHourly Rate\tHours Worked\tGross\n ");
    printf("%i\t\t\ t%0.2f\t\t%0.2f \t\t%0.2f\n", clock_number,
    hours_worked, hourly_rate, total);
    printf("Do you want to quit:");
    scanf("%c", &quitVal);
    goto done;

    done:

    return 0;
    }
Working...