1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| else if(ChoixDuMenu==3) // si l'utilisateur choisir de rechercher un contact..
{
printf("\nEntrez un bou de donnee du contact,nom,Prenom ou alias:\n");
scanf("%s",&Recherche);
printf("\nRecherche est:%s\n"); // juste pour verification
BListeContact=fopen("BListeContact.txt","r");// ouverture du fichier
if(BListeContact!=NULL)
{
printf("\n\nCONTACTS:\n\n");
while(fgets(LectureFichier,TAILLE_MAX,BListeContact)!=NULL)//parcours du fichier avec fgets
{
if(sscanf(LectureFichier,"%*s %*s %s %s %*s %s %*s %d",personne.nom,personne.prenom,personne.alias,personne.tel)==4)// et sscanf pour trouver exactement les 4 mots dans lesquels je comptre trouver le bout de chaine de caractere rechercher avec strstr
{
verification=strstr(LectureFichier,Recherche);
if(verification!=NULL)
{
printf("\nContact(s) correspondant(s) a votre recherche: %s\n",LectureFichier);// ma vision c'etait de parcourire a chaque fois ces 4 mots et voir si la chaine recherchee est dedans et s'il est dedans, j'affiche les 4 informations qui sont dans le "LectureFichier".. mais ca ne marche pas...
}
}
else
{
printf("\nSscanf non verifier!!\n");// ca saute pour afficher sscanf non verifier!
}
}
fclose(BListeContact);
}
else
{
printf("\nVotre repertoire est actuellement vide,ajoutez un contact dans le menu principal.\n");
}
printf("\n\nFin.\n\n"); |
Partager