lvlayhelvl
lvlayhelvl

Reputation: 19

Unresolved External Symbol in C

The Unresolved external symbol error is preventing the compilation of my code. It specifically is mentioning two functions being called in main. The functions are a part of a switch I am trying to create and it is still under construction. If anyone has any suggestions for how I can fix the bug or improve my code please let me know and thank you in advance. FYI- I already searched for similar questions and they are not specific to my problem...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//This is a macro intended for use with the emplyName array.
#define SIZE 20 

//This struct has all the varibles that I will be using in my functions
typedef struct person
{
    char* emplyName[5][SIZE];
    float emplyHours[5];
    float emplyRate[5];
    float emplyGross[5];
    float emplyBase[5];
    float emplyOvrt[5];
    float emplyTax[5];
    float emplyNet[5];
    float emplyTotal[5];
}input;

void menu(void);
void employeeInfo(input* emply);
void editEmployees(input* emply);
void print(input* emply);

int main(void)
{
    struct person *payroll={""};
    int choice = 0;
    menu();
    scanf_s("%c", &choice);
    switch (choice){
    case '1':
        employeeInfo(payroll);
        break;
    case '2':
        editEmployees(payroll);
        break;
    case '3':
        print(payroll);
        break;
    case '4':
        break;
    default:
        printf("Invalid entry\n");
    }
    system("pause");
}

void employeeInfo(input *emply)
{
    int i=0;
    do {
        printf("Enter employee name.\n");
        scanf_s("%s", &emply->emplyName[i]);
        printf("Enter employee hours.\n");
        scanf_s("%f", &emply->emplyHours[i]);
        printf("Enter Hourly rate.\n");
        scanf_s("%f", &emply->emplyRate[i]);
    } while (++i <= 5);

    void calculations(input *emply);/*Write a method that calculates the gross, base and overtime pay, pass by reference.*/
{
    int i;
    i = 0;
    for (i = 0; i < 5; i++){
        if (emply->emplyHours[i] > 40) {
            emply->emplyOvrt[i] = (emply->emplyHours[i] - 40) * (emply->emplyRate[i] * 1.5);
        }
        emply->emplyGross[i] = (((emply->emplyHours[i])*(emply->emplyRate[i])) + emply->emplyOvrt[i]);
        emply->emplyBase[i] = (emply->emplyGross[i]) - (emply->emplyOvrt[i]);
        emply->emplyTax[i] = ((emply->emplyGross[i])*.2);
        emply->emplyNet[i] = (emply->emplyGross[i]) - (emply->emplyTax[i]);
        emply->emplyTotal[0] += emply->emplyGross[i];
    }


}


void print(input *emply);
{
    int i;
    for (i = 0; i < 5; i++)
    {


        printf("Employee Name:%s\n", emply->emplyName[i]);
        printf("Hours Worked:%.2f\n ", emply->emplyHours[i]);
        printf("Hourly Rate:%.2f\n", emply->emplyRate[i]);
        printf("Gross Pay:%.2f\n", emply->emplyGross[i]);
        printf("Base Pay:%.2f\n", emply->emplyBase[i]);
        printf("Overtime Pay:%.2f\n", emply->emplyOvrt[i]);
        printf("Taxes Paid:%.2f\n", emply->emplyTax[i]);
        printf("Net Pay:%.2f\n", emply->emplyNet[i]);
    }
    printf("Total paid to all employees : %.2f\n", emply->emplyTotal[0]);
}
void editEmployees(input*emply);
{
    char edit;
    int i;
    printf("which employee would you like to edit?\n");
    for (i = 0; i < 5; i++){
        printf("%d.%s", i + 1, emply->emplyName[i]);
    }
    scanf_s("%c", &edit);
    switch (edit){
    case '1':
        printf("Enter employee name.\n");
        scanf_s("%s", &emply->emplyName[0]);
        printf("Enter employee hours.\n");
        scanf_s("%f", &emply->emplyHours[0]);
        printf("Enter Hourly rate.\n");
        scanf_s("%f", &emply->emplyRate[0]);
    }
}



}

void menu(void){
    printf("Main Menu\n");
    printf("1. Add Employee\n");
    printf("2. Edit Employee\n");
    printf("3. Print Employee\n");
    printf("4. Print All EMployees\n");
    printf("0. exit\n");

}

Upvotes: 0

Views: 2386

Answers (1)

alk
alk

Reputation: 70921

You defined editEmployees() and print() local to employeeInfo().

  1. This hides them from the the rest of the program.
  2. This is not Standard C.
  3. If you'd indented your code properly you most probably would have noticed this yourself.

Same for calculations().

Upvotes: 6

Related Questions