Code:
void addStaff()
{


	struct staff staa;
	char ans;
	FILE *fp;


	fp = fopen("staff.dat", "ab");


	printf("Add New staff (Y/N) : ");
	rewind(stdin);
	scanf(" %c", &ans);
	


	while (toupper(ans) == 'Y')
	{
		printf("Staff Details\n");
		printf("Staff ID:\n");
		scanf("%d", &staa.id);
		rewind(stdin);
		printf("Staff name:\n");
		scanf("%s", &staa.name);
		rewind(stdin);
		printf("Postion:\n");
		scanf("%s", &staa.position);
		rewind(stdin);
		printf("Salary");
		scanf("%d", &staa.salary);
		rewind(stdin);


		fwrite(&staa, sizeof(staa), 1, fp);
		printf("New staff details store successfully\n");
		printf("Are you want to add new staff details?(Y/N)");
		rewind(stdin);
		scanf("%c", &ans);
	}
	fclose(fp);
}
i like to alert the user if they enter the id that is already exist.
typedef struct staff {


	int id, salary;
	char name[30], position[30];


}staff;