Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C help

Name: D: 2008-05-07 2:35

I can't get this fucking code to read from a text file (payroll.txt) I have to include with the program. Maybe I'm a dumbass and not putting it in the right place (I put it in the root file where the code goes, but it's not working so...dunno). Anyway, pals, proofread my shitty code if you would be so kind.

/*This program prints a payroll register. It collects data from payroll.txt, an external file
that is put in the folder along with the program.*/

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

int main(void)
{
    int test;/*Used simply to stop the program from exiting*/
    FILE *payPtr;
    payPtr = fopen("payroll.txt", "r");
    int i = 1;
    int j = 1;
    double pay, fica, medicare, tax, dues, net, hoursOver;
    double dept200Pay, dept200Ins, dept200Fica, dept200Medicare, dept200Tax, dept200Dues, dept200Net;
    double dept300Pay, dept300Ins, dept300Fica, dept300Medicare, dept300Tax, dept300Dues, dept300Net;
   
    typedef struct {
       int department;
       char name[10];
       double rate;
       double hours;
       double insurance;
       double ytd;
       int code;
       } record; /*Ends structure department*/
       record employee;
   
    printf("%-10s\n%-10s\n", "Weekly Payroll Register", "by: Brad Widger");
    printf("%-6s%-2s%-30s%-3s%-5s", "Employee", "Gross", "Federal.", "Union", "Net");
    printf("Dept.%-4s%-7s%-4s%-3s%-4s%-5s%-6s%-6s", "Name", "Pay", "Insurance", "FICA", "MEDICARE", "Tax",
    "Dues", "Pay");
    printf("------------------------------------------------------------");
   
    while (!feof(payPtr)) {
    fscan(payPtr, "%d%s%lf%lf%lf%lf", &employee.department, &employee.name, &employee.rate,
    &employee.hours, &employee.insurance, &employee.ytd);
     /*end while*/
                    
                    
        if (employee.hours > 40) {
           pay = employee.rate * employee.hours;
           hoursOver = employee.rate - 40;
           pay = pay - (hoursOver * employee.rate) + (hoursOver * (employee.rate * 1.5));
              } /*end if*/
              else {
                   pay = employee.rate * employee.hours;
                   } /*end else*/
       
        if (employee.ytd > 65000.00) {
           fica = .05 * pay;
           medicare = .02 * pay;
           } /*end if*/
           else {
                fica = .07 * pay;
                medicare = .03 * pay;
                } /*end else*/
       
        tax = pay * .25;
       
        if (employee.code = 1) {
           dues = 35.00;
           } /*end if*/
           else {
                dues = 0.00;
                } /*end else*/
               
        net = pay - employee.insurance - fica - medicare - tax - dues;
       
        if (employee.department = 200) {
           printf("%d%s%lf%lf%lf%lf%lf%lf%lf", &employee.department, employee.name, &pay,
           &employee.insurance, &fica, &medicare, &tax, &dues, &net);
           dept200Pay =+ pay;
           dept200Ins =+ employee.insurance;
           dept200Fica =+ fica;
           dept200Medicare =+ medicare;
           dept200Tax =+ tax;
           dept200Dues =+ dues;
           dept200Net =+ net;
           } /*end if*/

        if (employee.department = 300) {
           printf("%d%s%lf%lf%lf%lf%lf%lf%lf", &employee.department, employee.name, &pay,
           &employee.insurance, &fica, &medicare, &tax, &dues, &net);
           dept300Pay =+ pay;
           dept300Ins =+ employee.insurance;
           dept300Fica =+ fica;
           dept300Medicare =+ medicare;
           dept300Tax =+ tax;
           dept300Dues =+ dues;
           dept300Net =+ net;
           } /*end if*/
          
 
  } /*end while*/
 
  /*fclose(payPtr);*/
  scanf("%d", &test); /*Stops program from ending*/

return 0;
} /*Ends main*/

Name: Anonymous 2008-05-07 10:23

>>17

SAY(1)                                           Speech Synthesis Manager                                           SAY(1)

NAME
       say - Convert text to audible speech

SYNOPSIS
           say [-v voice] [-o out.aiff | -n name:port ] [-f file | string ...]

DESCRIPTION
       This tool uses the Speech Synthesis manager to convert input text to audible speech and either play it through the
       sound output device chosen in System Preferences or save it to an AIFF file.

OPTIONS
       string
           Specify the text to speak on the command line. This can consist of multiple arguments, which are considered to
           be separated by spaces.

       -f file
           Specify a file to be spoken. If file is - or neither this parameter nor a message is specified, read from
           standard input.

       -v voice
           Specify the voice to be used. Default is the voice selected in System Preferences.

       -o out.aiff
           Specify an AIFF file to be written.

       -n name
       -n name:port
       -n :port
       -n :
           Specify a service name (default "AUNetSend") and/or IP port to be used for redirecting the speech output
           through AUNetSend.

       If the input is a TTY, text is spoken line by line, and the output file, if specified, will only contain audio for
       the last line of the input.  Otherwise, text is spoken all at once.

ERRORS
       say returns 0 if the text was spoken successfully, otherwise non-zero.  Diagnostic messages will be printed to
       standard error.

1.0                                                     2007-05-11                                                  SAY(1)

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List