[英]Unresolved External Symbol in C
无法解析的外部符号错误阻止了我的代码的编译。 具体来说,是提到main
中调用的两个函数。 这些功能是我尝试创建的开关的一部分,并且仍在构建中。 如果有人对如何解决该错误或改进我的代码有任何建议,请提前告知我并谢谢您。 仅供参考-我已经搜索了类似的问题,但它们并非特定于我的问题...
#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");
}
您定义了editEmployees()
本地的editEmployees()
和print()
employeeInfo()
。
对于calculations()
相同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.