![]() |
برنامج صغير ب س++ لحفظ المعلومات
dimanche 24 octobre 2010
les fichiers d'enregistrements.cpp donload:les fichiers d'enregistrements.exe #include <stdio.h> #include <conio.h> #include<stdlib.h> FILE *index; char rep; struct stagiaire { char nom[20]; char prenom[20]; int mtr; int dn; }; stagiaire stg; void creation() { index = fopen("C:\\Documents and Settings\\test.txt","w"); printf("tapez le nom "); scanf("%s",&stg.nom); printf("tapez le prenom "); scanf("%s",&stg.prenom); printf("tapez le mtr "); scanf("%d",&stg.mtr); printf("tapez le dn "); scanf("%d",&stg.dn); fprintf(index,"%s\n%s\n%d\n%d",& stg.nom,& stg.prenom,& stg.mtr,& stg.dn); fclose(index); } void ajout(){ index = fopen("C:\\Documents and Settings\\test.txt","a"); { printf("tapez le nom "); scanf("%s",&stg.nom); printf("tapez le prenom "); scanf("%s",&stg.prenom); printf("tapez le mtr "); scanf("%d",&stg.mtr); printf("tapez le dn "); scanf("%d",&stg.dn); fprintf(index,"%s\n%s\n%d\n%d",stg.nom,stg.prenom, stg.mtr,stg.dn);} fclose(index);} void consultation() { fscanf(index,"%s\n%s\n%d\n%d",stg.nom, stg.prenom,stg.mtr,stg.dn); printf(" nom %s",stg.nom); printf("prenom %s",stg.prenom); printf("mtr %d ",stg.mtr); printf("dn %d ",stg.dn); fclose(index); } main() { int ch; while(ch!=4) { system("cls"); printf("taper**************1-creation\n"); printf("taper**************2-ajout\n"); printf("taper**************3-consultation\n"); printf("taper**************4-quitter\n"); printf("entrer votre choix:"); scanf("%d",&ch); if(ch==1) creation(); if (ch==2) ajout(); if (ch==3) consultation(); } getch(); } source de allprogramation |
| الساعة الآن 02:27 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.