I'm working on a program in C language which collects data for the employees such as names, rates and hours. The thing is I need to use struct
.
I am trying to pass struct array into the load()
function where user will put names, hours and rates of the employee but it seems I'm doing it wrong. Can you tell me what is wrong?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define size 3
int i = 0;
struct Employee
{
char name[20];
float rate;
float hours;
}employee;
void load(struct Employee *guys);
void printout();
void edit();
void realedit();
void print();
int main(void)
{
int x=0;
struct Employee guys[size];
while (x != 5)
{
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("5. Quit");
scanf_s("%d", &x);
switch (x)
{
case 1: load(guys[i]);
break;
default: printf("Please enter valid option.\n\n");
break;
}
}
system("pause");
return 0;
}
void load(struct Employee *guys)
{
puts("\ntype name:\n");
scanf_s("%s", &guys[i]->name, 20);
puts("\ntype hourly rate:\n");
scanf_s("%f", &guys[i]->rate);
puts("\ntype hours worked:\n");
scanf_s("%f", &guys[i]->hours);
i++;
}