Bonjour tout le monde
voila, j'aimerais savoir comment modifier et supprimer un enregistrement de fichier en langage C, si quelqu'un pouvait m'aider, ce serait sympa.
J'ai deja essayé avec fseek et fwrite mai le pb est ek ca me cree une ligne en + donc jai toujour 2 ligne je ne sai pk
pointeur=fopen("ficpatient", "rt");
fread(&strpatient, sizeof(strpatient), 1, pointeur);
while (!feof(pointeur))
{
if (strcmp(strpatient.nom, nom)==0 && strcmp(strpatient.prenom, prenom)==0 && strcmp(strpatient.datenaiss, datenaiss)==0)
{
existe=1;
position=strpatient.num_patient;
}
fread(&strpatient, sizeof(strpatient), 1, pointeur);
}
fclose(pointeur);
if (position!=0)
{
pointeur=fopen("ficpatient", "r+t");
if (strcmp(nom,"")!=0) {
strcpy(strpatient.nom, nom); }
if (strcmp(prenom,"")!=0) {
strcpy(strpatient.prenom, prenom); }
if (strcmp(datenaiss,"")!=0) {
strcpy(strpatient.datenaiss, datenaiss); }
if (strcmp(adresse,"")!=0) {
strcpy(strpatient.adresse, adresse); }
if (strcmp(cp,"")!=0) {
strcpy(strpatient.cp, cp); }
if (strcmp(ville,"")!=0) {
strcpy(strpatient.ville, ville); }
if (strcmp(tel,"")!=0) {
strcpy(strpatient.tel, tel); }
if (strcmp(numss,"")!=0) {
strcpy(strpatient.numss, numss); }
fseek(pointeur, sizeof(strpatient)*(position), SEEK_SET);
fwrite(&strpatient, sizeof(strpatient), 1, pointeur);
printf("\nLes coordonnees du patient %d ont ete modifiees.\n", strpatient.num_patient);
fclose(pointeur);
merci d'avance a tou ceux ki pouron maider
@+++++++
mika