hi everyone pls do me a favor i worked for my project using a simple textfile pass by parameter without using a sturcture...the ff. code must like this
add record, update record, search record, delete record. the pls add a code that you like to add, update, search, delete a record? thank you so much guy
void AddNewRecord(FILE * fp, struct IDDATA e, long int IDDATASIZE)
{
struct IDDATA tmp;
clrscr();
printf("ADD NEW RECORD FORM\n");
printf("ID No. : \n ");
gets(e.ID);
printf("First Name : ");
gets(e.Fname);
printf("Middle Name : ");
gets(e.Mname);
printf("Last Name : ");
gets(e.Lname);
printf("Course : ");
gets(e.course);
printf("College : ");
gets(e.college);
fseek(fp,0,SEEK_END);
fwrite(&e,IDDATASIZE,1,fp);
printf("Add Another Record? ( Y=[yes] or N=[no] ) : ");
fflush(stdout);
scanf("%c",&choice);
fclose(fp);
}
void SortID(struct IDDATA temp[], int tempsize)
{
int a, b, c=0;
struct IDDATA tmp;
for (a = 1; a<tempsize ; a++) {
for (b = 0; b < tempsize - 1; b++)
{
if (atoi(temp[b].ID) > atoi(temp[b + 1].ID)) // compares current array and next array has the highest value
{
tmp = temp[b]; // temporarily store highest value to tmp variable
temp[b] = temp[b + 1]; // select next array and store value from next array.
temp[b + 1] = tmp; // sets the current array as has the highest value
}
}
}