hello guys i got this exercice in which i need help. This program should fill two arrays made of information about students and employee. i have to sort alphabetically each of them by name and last name, still i have to check that no name should be repeated. In this program i tried to store the information in a table string"std" and in the same time check for any repeated name but i have problem with the sorting and when i run this it shuts down as the size ins't recognized even if i specified it.
Code:
#include <stdio.h>
#include <conio.h>
#include <string.h>
#define SIZE 10;
typedef struct {
char *firstname;
char *lastname;
float grade;
}student;
typedef struct {
char *lastname;
char *firstname;
float salary;
}employee;
void fill_1(student []);
void fill_s(student);
void fill_2(employee *);
void fill_e(employee []);
int search(student [],student );
int main()
{
student s[10];
student std;
fill_1(s);
}
void fill_e(employee *e)
{
printf("please enter first name");
scanf("%s",&e->firstname);
printf("please enter last name");
scanf("%s",&e->lastname);
printf("please enter grade");
scanf("%f",&e->salary);
}
void fill_s(student *s)
{
printf("please enter first name");
scanf("%s",&s->firstname);
printf("please enter last name");
scanf("%s",&s->lastname);
printf("please enter grade");
scanf("%f",&s->grade);
}
void fill_1(student s[])
{
int i=0,test;
student std;
fill_s(&std);
s[0]=std;
do{
fill_s(&std);
if(search(s,std)==1) printf("no");
else s[i+1]=std;
i++;
printf("entrez 0,1");
scanf("%d", &test);
}while((i<10)&&(test==1));
}
void fill_2(employee e[])
{
int i=0,test;
do
{
fill_e(&e[i]);
printf("if you want to add another employee press 1 else press 0");
scanf ("%d",&test);
i=i+1;
}while((i<10)&&(test==1));
}
int search(student s[],student std)
{
for(int i=0;i<10;i++)
{
if ((strcmp(s[i].firstname,std.firstname)==0) && (strcmp(s[i].lastname,std.lastname)==0))
return 1;
} return 0;}