Hi guys! I'm a newbie here. I've been working on my program and I want to know how do you find duplicates in the binary file? For example, The user entered xx-xxx account#. If the account# is duplicate, the program informs the user. What should i use in finding duplicates? fread()?
Code:void Input(FILE *fp, struct information info, char set[]){ char gen; fp=fopen("account.dat","a+b"); if(strlen(info.id)==0); { system("cls"); printf("Enter Account ID(xx-xxx): "); scanf("%6s",info.id); if (info.id[2]!='-' || strspn(info.id,set)!=6) { system("cls"); printf("Invalid ID format! "); getch(); } if(strcmp(info.id??)==0) What should i do here to find duplicates? fread() looping? fflush(stdin); printf("Enter the First Name: "); gets(info.fname); printf("Enter the Middle Name: "); gets(info.mname); printf("Enter the Last Name: "); gets(info.lname); printf("Enter the Address: "); gets(info.address); printf("Enter gender specification[M/F]: "); gen=toupper(getche()); info.gender=gen; fwrite(&info, sizeof(struct information), 1, fp); } fclose(fp); }



LinkBack URL
About LinkBacks


