td6
45
td6.md
45
td6.md
@@ -144,6 +144,20 @@ void menu_creationcompte() {
|
||||
}
|
||||
```
|
||||
|
||||
La fonction pour vérifier la date
|
||||
|
||||
```c
|
||||
int verif_date(char *chaine) {
|
||||
if (strlen(chaine)!=10) return 0;
|
||||
if (chaine[2] != '/') return 0;
|
||||
if (chaine[5] != '/') return 0;
|
||||
if (chaine[0]< '0' || chaine[0] > '3') return 0;
|
||||
if (chaine[3]< '0' || chaine[3] > '1') return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
```
|
||||
|
||||
### Enregistrement d’opération
|
||||
|
||||
* L’utilisateur choisit un compte existant.
|
||||
@@ -168,6 +182,37 @@ ID Nom Prénom Solde (€)
|
||||
Choisissez un ID pour voir le détail (0 = retour) :
|
||||
```
|
||||
|
||||
```c
|
||||
void menu_listercompte() {
|
||||
|
||||
clear();
|
||||
mvprintw(0, 0, "====================================");
|
||||
mvprintw(1, 0, " Liste des comptes ");
|
||||
mvprintw(2, 0, "====================================");
|
||||
|
||||
Compte compte;
|
||||
|
||||
FILE *fichier = fopen("comptes.dat", "rb");
|
||||
if (!fichier) {
|
||||
mvprintw(3, 0, "** Erreur d'ouverture du fichier **");
|
||||
getch();
|
||||
return;
|
||||
}
|
||||
|
||||
int i = 1;
|
||||
while (fread(&compte, sizeof(Compte), 1, fichier)!=0) {
|
||||
mvprintw(2 + i, 0, "%d", i);
|
||||
mvprintw(2 + i, 3, compte.nom);
|
||||
mvprintw(2 + i, 15, compte.prenom);
|
||||
mvprintw(2 + i, 30, "%.2f", compte.solde);
|
||||
i++;
|
||||
}
|
||||
|
||||
getch(); /* Il faut que l'utilisateur appuie sur une touche sinon l'affichage repart directement sur
|
||||
l'écran principal et on n'a le temps de ne rien voir. */
|
||||
}
|
||||
```
|
||||
|
||||
* Si un compte est sélectionné, afficher l’historique des opérations :
|
||||
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user