Accueil > > > GESTION SCOLAIRE
GESTION SCOLAIRE
Information sur la source
Description
Bonjour ;
Je propose un programme simle et exploitant la notion de fichiers en C (sous Turbo C).
Ici, j'ai traité un exemple pratique : gestion scolaire primitive (Ajouter un étudiant, supprimer, modifier, consulter, trier...etc).
Je serais content de recevoir vos critiques, remarques ou suggestions constructive.
BEGUERADJ from Algeria (BEJAIA) : beg.bill@yahoo.com.
Merci !
Source
- // This is done by Billal BEGIUERADJ
- // Student File management
- // Code Built up in C
- // beg.bill@yahoo.com
- //Algeria //BEJAIA
-
-
- #include<stdio.h>
- #include<conio.h>
- #include<string.h>
- #include<dos.h>
-
- typedef struct etudiant
- {int mat;char nom[20],prenom[20];float moy;};
- void creation (FILE *x);
- void insertion(FILE *x);
- void affichage_moy(FILE *x);
- void affichage_nom(FILE *x);
- void affichage_sequen(FILE *x);
- void recherche_nom(FILE *x);
- void recherche_mat(FILE *x);
- void suppression_moy(FILE *x);
- void suppression_mat(FILE *x);
- void calcul(FILE *x);
- void affiche();
- void s_menu1();
- void s_menu2();
- void s_menu3();
- void cadre();
- void music();
- //*******************************************************
-
- void main()
- {
- FILE *x;
- //char t[30]={}
- int choix;
-
- start:
- textbackground(RED);
- clrscr();
- cadre();
- gotoxy(30,3);
- printf("** Le MENU PRINCIPAL **");
- gotoxy(30,4);
- printf("=======================");
- gotoxy(8,6);
- printf("1 -----> Création.");
- gotoxy(8,8);
- printf("2 -----> Insertion.");
- gotoxy(8,10);
- printf("3 -----> Listing (Affichage). ");
- gotoxy(8,12);
- printf("4 -----> Suppression. ");
- gotoxy(8,14);
- printf("5 -----> Recherche.");
- gotoxy(8,16);
- printf("6 -----> Calcul de la moyenne de la promotion");
- gotoxy(8,18);
- printf("7 -----> Quitter l\'application");
-
- gotoxy(30,21);
- printf("Votre choix SVP : ");
- scanf("%d",&choix);
- clrscr();
- switch(choix)
- {
- case 1: gotoxy(25,2);
- printf("CREATION");
- creation(x);
- goto start;
-
- case 2: gotoxy(25,2);
- printf("L'INSERTION");
- insertion(x);
- goto start;
-
- case 3: gotoxy(25,2);
- printf("AFFICHAGE");
- s_menu2();
- goto start;
-
- case 4: gotoxy(25,2);
- printf("SUPPRISSION ");
- s_menu1();
- goto start;
-
- case 5: gotoxy(25,2);
- printf("RECHERCHE");
- s_menu3();
- goto start;
-
- case 6: gotoxy(25,2);
- printf("CALCUL ");
- calcul(x);
- goto start;
-
- case 7: gotoxy(25,2);
- gotoxy(22,8);
- textmode(C40);
- textcolor(YELLOW+BLINK) ;
- cprintf("\n\n\n\n\n\n\t\t\t\t\t\t\t\t\t BEGUERADJ Billal\t\t\t\t\t\t");
- cprintf("\n\n\n\n\t\t\t\t\t\t\t\t beg.bill@yahoo.com\t\t\t\t\t\t");
- break;
- default :gotoxy(20,3);
- printf("CHOIX NON LISTE ! ");
- getch();
- goto start;
-
- }
- getch();
- }
- //************************************************************
-
- void s_menu1(){ FILE *x;
- int choix1;
- cadre();
- textcolor(2);
- gotoxy(15,8);
- printf("1 ------> SUPPRESSION DES ETUDIANTS AYANTS UNE MOYENNE <10");
- gotoxy(15,10);
- printf("2 ------>SUPPRESSION DES ETUDAINTS PAR MATRICULE");
- gotoxy(30,15);
- printf("DONNER VOTRE CHOIX SVP ? ");
- scanf("%d",&choix1);
- switch(choix1) {
- case 1: clrscr();
- gotoxy(5,2);
- printf("SUPPRESSION DES ETUDAINTS AYANTS UNE MOYENNE <10 ");
- break;
-
- case 2: clrscr();
- gotoxy(5,2);
- printf("SUPPRESSION DES ETUDIANTS PAR MATRICULE ");
- suppression_mat(x);
- break;
-
- default :gotoxy(10,20);
- printf("VOTRE CHOIX N'EXISTE PAS DANS LE MENU !");
- getch();
- break;
- }
- }
-
- //*********************************************************************
-
- void s_menu2(){
- FILE *x;
- int choix2;
- cadre();
- textcolor(6);
- gotoxy(8,8);
- printf("1 ------> AFFICHAGE DES ETUDIANTS PAR ORDRE ALPHABITIQUE");
- gotoxy(8,10);
- printf("2 ------> AFFICHAGE DES ETUDAINTS PAR ORDRE CROISSANT DE LEURS MOYENNE");
- gotoxy(8,12);
- printf("3 ------> AFFICHAGE DES ETUDAINTS PAR ORDRE DE LEURS ARRIVES (sequenciel)");
- gotoxy(20,20);
- printf("VOTRE CHOIX SVP : ");
- scanf("%d",&choix2);
- switch(choix2) {
- case 1: printf("\nL'AFFICHAGE DES ETUDAINTS PAR ORDRE ALPHABITIQUE DE LEURS NOM");
- affichage_nom(x);
- break;
-
- case 2: printf("\nL'AFFICHAGE DES ETUDIANTS PAR OREDRE CROISSANT DE LEURS MOYENNE ");
- affichage_moy(x);
- break;
-
- case 3: printf("\nL'AFFICHAGE DES ETUDIANTS PAR OREDRE DE LEURS ARRIVES ");
- affichage_sequen(x);
- break;
-
- default :printf("\nVOTRE CHOIX N'EXISTE PAS DANS LE MENU !");break;
- }
- }
-
- //*********************************************************************
-
- void s_menu3(){
- FILE *x;
- int choix3;
- cadre();
- textcolor(2);
- gotoxy(15,8);
- printf("1 ------> RECHERCHE D'ETUDIANT IDENTIFIE PAR SON NOM");
- gotoxy(15,10);
- printf("2 ------> RECHERCHE D'UN ETUDAINTS IDENTIFIE PAR SON MATRICULE");
- gotoxy(25,15);
- printf("VOTRE CHOIX SVP : ");
- scanf("%d",&choix3);
- clrscr();
- cadre();
- switch(choix3) {
- case 1:
- gotoxy(5,2);
- printf("LA RECHERCHE D'UN ETUDAINT IDENTIFIE PAR SON NOM");
- recherche_nom(x);
- break;
-
- case 2:
- gotoxy(5,2);
- printf("LA RECHERCHE D'UN ETUDIANT IDENTIFIE PAR MATRICULE ");
- recherche_mat(x);
- break;
-
- default :gotoxy(5,4); printf("VOTRE CHOIX N'EXISTE PAS DANS LE MENU !");
- getch();
- break;
- }
- }
-
- //*********************************************************************
-
- void creation(FILE *x)
- {
- etudiant e ;
- int n,k ;
- char r;
-
-
- textcolor(2);
- cadre();
- gotoxy(20,4);
-
- printf("ALERTE");
- gotoxy(5,6);
- printf(" CETTE FONCTION VA CREER UN NOUVEAU FICHIER");
- gotoxy(10,8);
- printf("SI LE FICHIER EXISTE DEJA");
- gotoxy(5,10);
- printf("VOUS RESQUEZ DE PERDRE LES INFORMATIONS QUI CONTIENT");
- music();
- gotoxy(5,20);
- printf("Etes vous sur de vouloir cr‚er un nouveau fichier ? o/n : ");
- r=getch();
- if (r=='n') {goto fin;}
- //sleep(7);
- clrscr();
- cadre();
- gotoxy(5,4);
- textcolor(3);
- printf("Donnez le nombre d'etudiant a ecrire dans le fichier : ");
- scanf("%d",&n);
- clrscr();
- x=fopen("etudiant.dat","w");
- textcolor(11);
- for (k=0;k<n;++k)
- {
- clrscr();
- cadre();
- gotoxy(25,5);
- printf("L'etudiant Nø%d",k+1);
- affiche();
- gotoxy(34,8);
- scanf("%d",&e.mat);
- gotoxy(34,10);
- scanf("%s",e.nom);
- gotoxy(34,12);
- scanf("%s",e.prenom);
- gotoxy(34,14);
- scanf("%f",&e.moy);
- fwrite(&e,sizeof(etudiant),1,x);
- //getch();
- }
- fclose(x);
- fin:
- }
-
- //*************************************************************
-
- void insertion (FILE *x)
- {
- int nbr,j,n=0;
- etudiant e;
- cadre();
- gotoxy(5,4);
- textcolor(3);
- printf("Donnez le nombre d'etudiant a insérer dans le fichier : ");
- scanf("%d",&nbr);
- clrscr();
- cadre();
- textcolor(11);
- x=fopen("etudiant.dat","r+");
- while(!feof(x))
- {
- fread(&e,sizeof(etudiant),1,x); n++;
- }
- for (j=0;j<nbr;++j)
- {
- clrscr();
- cadre();
- gotoxy(25,5);
- printf("L'etudiant Nø%d",n++);
- affiche();
- gotoxy(34,8);
- scanf("%d",&e.mat);
- gotoxy(34,10);
- scanf("%s",e.nom);
- gotoxy(34,12);
- scanf("%s",e.prenom);
- gotoxy(34,14);
- scanf("%f",&e.moy);
- fwrite(&e,sizeof(etudiant),1,x);
- // getch();
- }
- fclose(x);
- }
- //***********************************************************
-
- void affiche()
- {
- textcolor(7);
- gotoxy(5,8);
- printf("La matricule de l'‚tudiant ");
- gotoxy(5,10);
- printf("Le nom de l'‚tudiant ");
- gotoxy(5,12);
- printf("Le prenom de l'etudiant ");
- gotoxy(5,14);
- printf("La moyenne g‚n‚rale ");
- }
-
- //***********************************************************
-
- void affichage_sequen(FILE *x)
- {
- etudiant e;
- int i=1;
-
- x=fopen("etudiant.dat","r");
- textcolor(13);
- fread(&e,sizeof(etudiant),1,x);
- do
- {
- gotoxy(25,5);
- printf("L'ETUDIANT Nø %d ",i);
- clrscr();
- cadre();
- affiche();
-
- gotoxy(34,8);
- printf("%d",e.mat);
- gotoxy(34,10);
- printf("%s",e.nom);
- gotoxy(34,12);
- printf("%s",e.prenom);
- gotoxy(34,14);
- printf("%2.2f",e.moy);
- fread(&e,sizeof(etudiant),1,x);
- getch(); i++;
- } while (!feof(x));
- fclose(x);
- }
-
- //***********************************************************************
-
- void affichage_moy(FILE *x)
- {
- etudiant t[20],e;
- int i,j,k=0;
-
- x=fopen("etudiant.dat","r");
- fread(&e,sizeof(etudiant),1,x);
- do{
- t[k]=e ;
- fread(&e,sizeof(etudiant),1,x);
- k++;
- } while (!feof(x));
- fclose(x);
- for(i=0;i<k;i++){
- for (j=i+1;j<k;j++)
- {
- if(t[i].moy>=t[j].moy)
- {
- e=t[i];
- t[i]=t[j];
- t[j]=e;
- }
- }
- textcolor(13);
- gotoxy(25,5);
- printf("L'ETUDIANT Nø %d ",i);
- clrscr();
- cadre();
- affiche();
- gotoxy(34,8);
- printf("%d",t[i].mat);
- gotoxy(34,10);
- printf("%s",t[i].nom);
- gotoxy(34,12);
- printf("%s",t[i].prenom);
- gotoxy(34,14);
- printf("%2.2f",t[i].moy);
- getch();
- }
- }
-
-
- //**********************************************************************/
-
- void affichage_nom(FILE *x)
- {
- etudiant t[20],e;
- int i,j,k=0;
-
- cadre();
- gotoxy(5,5);
- printf("VOUS AVEZ CHOISI L'AFFICHAGE DES ETUDAINTS PAR ORDRE ALPHABITIQUE ");
- gotoxy(15,6);printf("DE LEURS NOM");
- sleep(3);
- x=fopen("etudiant.dat","r");
- fread(&e,sizeof(etudiant),1,x);
- do{
- t[k]=e ;
- fread(&e,sizeof(etudiant),1,x);
- k++;
- } while (!feof(x));
- fclose(x);
- for(i=0;i<k;i++){
- for (j=i+1;j<k;j++){
- if (strcmp(t[i].nom,t[j].nom)>0){
- e=t[i];
- t[i]=t[j];
- t[j]=e;
- }
- }
- clrscr();
- cadre();
- affiche();
- gotoxy(34,8);
- printf("%d",t[i].mat);
- gotoxy(34,10);
- printf("%s",t[i].nom);
- gotoxy(34,12);
- printf("%s",t[i].prenom);
- gotoxy(34,14);
- printf("%2.2f",t[i].moy);
- getch();
- }
- }
-
- /***********************************************************************/
-
- void calcul(FILE *x){
- etudiant e;
- float m=0 ;
- int i=0;
-
- x=fopen("etudiant.dat","r");
- fread(&e,sizeof(etudiant),1,x);
- while (!feof(x)){
- m=m+e.moy ;
- i++;
- fread(&e,sizeof(etudiant),1,x);
- }
- if(i!=0){
- m=m/i;
- }
- cadre();
- gotoxy(5,7);
- printf("La moyenne de la promotion est: %2.2f",m);
- getch();
- }
-
- /**************************************************************************/
-
- void recherche_nom(FILE*x){
- etudiant e;
- char nom2[20];
- int i=0;
-
- gotoxy(7,4);
- printf("donner le nom de l'etudiant a chercher ");
- scanf("%s",nom2);
- x=fopen("etudiant.dat","r");
- while(!feof(x)){
- fread(&e,sizeof(etudiant),1,x);
- if(strcmp(e.nom,nom2)==0) {
- i=1;
- affiche();
- gotoxy(34,8);
- printf("%d",e.mat);
- gotoxy(34,10);
- printf("%s",e.nom);
- gotoxy(34,12);
- printf("%s",e.prenom);
- gotoxy(34,14);
- printf("%2.2f",e.moy);
- fread(&e,sizeof(etudiant),1,x);
- }
- }
- if(i==0){
- gotoxy(25,10);
- printf("CET ETUDIANT N'EXISTE PAS");}
- getch();
- }
-
- //**********************************************************************
-
- void recherche_mat(FILE*x){
- etudiant e; int matr;
- int i=0;
-
- gotoxy(7,4);
- printf("donner le matricule de l'etudiant a chercher ");
- scanf("%d",&matr);
- x=fopen("etudiant.dat","r");
- while(!feof(x)){
- fread(&e,sizeof(etudiant),1,x);
- if(e.mat==matr) {
- i=1;
- affiche();
- gotoxy(34,8);
- printf("%d",e.mat);
- gotoxy(34,10);
- printf("%s",e.nom);
- gotoxy(34,12);
- printf("%s",e.prenom);
- gotoxy(34,14);
- printf("%2.2f",e.moy);
- fread(&e,sizeof(etudiant),1,x);
- getch();
- }
- }
- if(i==0)
- {gotoxy(25,10);
- printf("CET ETUDIANT N'EXISTE PAS");}
- getch();
- }
-
- //*************************************************************
- /*------------------- DESSIN DE CADRE-------------------*/
- void cadre(){
- int i;
-
- clrscr();
- for(i=3;i<78;i++){
- gotoxy(i,1);
- printf("");
- gotoxy(i,22);
- printf("*");
- gotoxy(i,25);
- printf("");}
-
- for (i=0;i<26;i++){
- gotoxy(3,i);
- printf("");
- gotoxy(78,i);
- printf(""); }
-
-
- gotoxy(8,24);
- printf("");
- }
- /************************************************************/
- void music(){
- int i;
-
- for(i=0;i<7;i++){
- sound(100*i);
- delay(300*i);
- nosound(); }
- }
-
-
- /************************************************************/
- void suppression_mat(FILE *x){
- FILE *y;
- etudiant e;
- int mat ,pos;
- char re;
-
- cadre();
- //sleep(2);
- //clrscr();
- gotoxy(6,4);
- printf("Donnez la matricule de l'etudiant a suppremer ?: ");
- scanf("%d",&mat);
- gotoxy(5,8);
- printf("etes vous sur de vouloir supprimer l'etudiant de matricule %d ? o/n",mat);
- re=getch();
- if(re=='n')goto not_del;
- y=fopen("etud.dat","w");
- x=fopen("etudiant.dat","r");
- // i=0;
- while(!feof(x)){
- fread(&e,sizeof(etudiant),1,x);
- if(e.mat!=mat) {
- //i++;
- fwrite(&e,sizeof(etudiant),1,y);
- }
- }
- fclose(x);
- fclose(y);
- x=fopen("etudiant.dat","w");
- y=fopen("etud.dat","r");
- while(!feof(y)){
- fread(&e,sizeof(etudiant),1,y);
- fwrite(&e,sizeof(etudiant),1,x);
- }
- fclose(x);
- fclose(y);
- not_del:
- }
// This is done by Billal BEGIUERADJ
// Student File management
// Code Built up in C
// beg.bill@yahoo.com
//Algeria //BEJAIA
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<dos.h>
typedef struct etudiant
{int mat;char nom[20],prenom[20];float moy;};
void creation (FILE *x);
void insertion(FILE *x);
void affichage_moy(FILE *x);
void affichage_nom(FILE *x);
void affichage_sequen(FILE *x);
void recherche_nom(FILE *x);
void recherche_mat(FILE *x);
void suppression_moy(FILE *x);
void suppression_mat(FILE *x);
void calcul(FILE *x);
void affiche();
void s_menu1();
void s_menu2();
void s_menu3();
void cadre();
void music();
//*******************************************************
void main()
{
FILE *x;
//char t[30]={}
int choix;
start:
textbackground(RED);
clrscr();
cadre();
gotoxy(30,3);
printf("** Le MENU PRINCIPAL **");
gotoxy(30,4);
printf("=======================");
gotoxy(8,6);
printf("1 -----> Création.");
gotoxy(8,8);
printf("2 -----> Insertion.");
gotoxy(8,10);
printf("3 -----> Listing (Affichage). ");
gotoxy(8,12);
printf("4 -----> Suppression. ");
gotoxy(8,14);
printf("5 -----> Recherche.");
gotoxy(8,16);
printf("6 -----> Calcul de la moyenne de la promotion");
gotoxy(8,18);
printf("7 -----> Quitter l\'application");
gotoxy(30,21);
printf("Votre choix SVP : ");
scanf("%d",&choix);
clrscr();
switch(choix)
{
case 1: gotoxy(25,2);
printf("CREATION");
creation(x);
goto start;
case 2: gotoxy(25,2);
printf("L'INSERTION");
insertion(x);
goto start;
case 3: gotoxy(25,2);
printf("AFFICHAGE");
s_menu2();
goto start;
case 4: gotoxy(25,2);
printf("SUPPRISSION ");
s_menu1();
goto start;
case 5: gotoxy(25,2);
printf("RECHERCHE");
s_menu3();
goto start;
case 6: gotoxy(25,2);
printf("CALCUL ");
calcul(x);
goto start;
case 7: gotoxy(25,2);
gotoxy(22,8);
textmode(C40);
textcolor(YELLOW+BLINK) ;
cprintf("\n\n\n\n\n\n\t\t\t\t\t\t\t\t\t BEGUERADJ Billal\t\t\t\t\t\t");
cprintf("\n\n\n\n\t\t\t\t\t\t\t\t beg.bill@yahoo.com\t\t\t\t\t\t");
break;
default :gotoxy(20,3);
printf("CHOIX NON LISTE ! ");
getch();
goto start;
}
getch();
}
//************************************************************
void s_menu1(){ FILE *x;
int choix1;
cadre();
textcolor(2);
gotoxy(15,8);
printf("1 ------> SUPPRESSION DES ETUDIANTS AYANTS UNE MOYENNE <10");
gotoxy(15,10);
printf("2 ------>SUPPRESSION DES ETUDAINTS PAR MATRICULE");
gotoxy(30,15);
printf("DONNER VOTRE CHOIX SVP ? ");
scanf("%d",&choix1);
switch(choix1) {
case 1: clrscr();
gotoxy(5,2);
printf("SUPPRESSION DES ETUDAINTS AYANTS UNE MOYENNE <10 ");
break;
case 2: clrscr();
gotoxy(5,2);
printf("SUPPRESSION DES ETUDIANTS PAR MATRICULE ");
suppression_mat(x);
break;
default :gotoxy(10,20);
printf("VOTRE CHOIX N'EXISTE PAS DANS LE MENU !");
getch();
break;
}
}
//*********************************************************************
void s_menu2(){
FILE *x;
int choix2;
cadre();
textcolor(6);
gotoxy(8,8);
printf("1 ------> AFFICHAGE DES ETUDIANTS PAR ORDRE ALPHABITIQUE");
gotoxy(8,10);
printf("2 ------> AFFICHAGE DES ETUDAINTS PAR ORDRE CROISSANT DE LEURS MOYENNE");
gotoxy(8,12);
printf("3 ------> AFFICHAGE DES ETUDAINTS PAR ORDRE DE LEURS ARRIVES (sequenciel)");
gotoxy(20,20);
printf("VOTRE CHOIX SVP : ");
scanf("%d",&choix2);
switch(choix2) {
case 1: printf("\nL'AFFICHAGE DES ETUDAINTS PAR ORDRE ALPHABITIQUE DE LEURS NOM");
affichage_nom(x);
break;
case 2: printf("\nL'AFFICHAGE DES ETUDIANTS PAR OREDRE CROISSANT DE LEURS MOYENNE ");
affichage_moy(x);
break;
case 3: printf("\nL'AFFICHAGE DES ETUDIANTS PAR OREDRE DE LEURS ARRIVES ");
affichage_sequen(x);
break;
default :printf("\nVOTRE CHOIX N'EXISTE PAS DANS LE MENU !");break;
}
}
//*********************************************************************
void s_menu3(){
FILE *x;
int choix3;
cadre();
textcolor(2);
gotoxy(15,8);
printf("1 ------> RECHERCHE D'ETUDIANT IDENTIFIE PAR SON NOM");
gotoxy(15,10);
printf("2 ------> RECHERCHE D'UN ETUDAINTS IDENTIFIE PAR SON MATRICULE");
gotoxy(25,15);
printf("VOTRE CHOIX SVP : ");
scanf("%d",&choix3);
clrscr();
cadre();
switch(choix3) {
case 1:
gotoxy(5,2);
printf("LA RECHERCHE D'UN ETUDAINT IDENTIFIE PAR SON NOM");
recherche_nom(x);
break;
case 2:
gotoxy(5,2);
printf("LA RECHERCHE D'UN ETUDIANT IDENTIFIE PAR MATRICULE ");
recherche_mat(x);
break;
default :gotoxy(5,4); printf("VOTRE CHOIX N'EXISTE PAS DANS LE MENU !");
getch();
break;
}
}
//*********************************************************************
void creation(FILE *x)
{
etudiant e ;
int n,k ;
char r;
textcolor(2);
cadre();
gotoxy(20,4);
printf("ALERTE");
gotoxy(5,6);
printf(" CETTE FONCTION VA CREER UN NOUVEAU FICHIER");
gotoxy(10,8);
printf("SI LE FICHIER EXISTE DEJA");
gotoxy(5,10);
printf("VOUS RESQUEZ DE PERDRE LES INFORMATIONS QUI CONTIENT");
music();
gotoxy(5,20);
printf("Etes vous sur de vouloir cr‚er un nouveau fichier ? o/n : ");
r=getch();
if (r=='n') {goto fin;}
//sleep(7);
clrscr();
cadre();
gotoxy(5,4);
textcolor(3);
printf("Donnez le nombre d'etudiant a ecrire dans le fichier : ");
scanf("%d",&n);
clrscr();
x=fopen("etudiant.dat","w");
textcolor(11);
for (k=0;k<n;++k)
{
clrscr();
cadre();
gotoxy(25,5);
printf("L'etudiant Nø%d",k+1);
affiche();
gotoxy(34,8);
scanf("%d",&e.mat);
gotoxy(34,10);
scanf("%s",e.nom);
gotoxy(34,12);
scanf("%s",e.prenom);
gotoxy(34,14);
scanf("%f",&e.moy);
fwrite(&e,sizeof(etudiant),1,x);
//getch();
}
fclose(x);
fin:
}
//*************************************************************
void insertion (FILE *x)
{
int nbr,j,n=0;
etudiant e;
cadre();
gotoxy(5,4);
textcolor(3);
printf("Donnez le nombre d'etudiant a insérer dans le fichier : ");
scanf("%d",&nbr);
clrscr();
cadre();
textcolor(11);
x=fopen("etudiant.dat","r+");
while(!feof(x))
{
fread(&e,sizeof(etudiant),1,x); n++;
}
for (j=0;j<nbr;++j)
{
clrscr();
cadre();
gotoxy(25,5);
printf("L'etudiant Nø%d",n++);
affiche();
gotoxy(34,8);
scanf("%d",&e.mat);
gotoxy(34,10);
scanf("%s",e.nom);
gotoxy(34,12);
scanf("%s",e.prenom);
gotoxy(34,14);
scanf("%f",&e.moy);
fwrite(&e,sizeof(etudiant),1,x);
// getch();
}
fclose(x);
}
//***********************************************************
void affiche()
{
textcolor(7);
gotoxy(5,8);
printf("La matricule de l'‚tudiant ");
gotoxy(5,10);
printf("Le nom de l'‚tudiant ");
gotoxy(5,12);
printf("Le prenom de l'etudiant ");
gotoxy(5,14);
printf("La moyenne g‚n‚rale ");
}
//***********************************************************
void affichage_sequen(FILE *x)
{
etudiant e;
int i=1;
x=fopen("etudiant.dat","r");
textcolor(13);
fread(&e,sizeof(etudiant),1,x);
do
{
gotoxy(25,5);
printf("L'ETUDIANT Nø %d ",i);
clrscr();
cadre();
affiche();
gotoxy(34,8);
printf("%d",e.mat);
gotoxy(34,10);
printf("%s",e.nom);
gotoxy(34,12);
printf("%s",e.prenom);
gotoxy(34,14);
printf("%2.2f",e.moy);
fread(&e,sizeof(etudiant),1,x);
getch(); i++;
} while (!feof(x));
fclose(x);
}
//***********************************************************************
void affichage_moy(FILE *x)
{
etudiant t[20],e;
int i,j,k=0;
x=fopen("etudiant.dat","r");
fread(&e,sizeof(etudiant),1,x);
do{
t[k]=e ;
fread(&e,sizeof(etudiant),1,x);
k++;
} while (!feof(x));
fclose(x);
for(i=0;i<k;i++){
for (j=i+1;j<k;j++)
{
if(t[i].moy>=t[j].moy)
{
e=t[i];
t[i]=t[j];
t[j]=e;
}
}
textcolor(13);
gotoxy(25,5);
printf("L'ETUDIANT Nø %d ",i);
clrscr();
cadre();
affiche();
gotoxy(34,8);
printf("%d",t[i].mat);
gotoxy(34,10);
printf("%s",t[i].nom);
gotoxy(34,12);
printf("%s",t[i].prenom);
gotoxy(34,14);
printf("%2.2f",t[i].moy);
getch();
}
}
//**********************************************************************/
void affichage_nom(FILE *x)
{
etudiant t[20],e;
int i,j,k=0;
cadre();
gotoxy(5,5);
printf("VOUS AVEZ CHOISI L'AFFICHAGE DES ETUDAINTS PAR ORDRE ALPHABITIQUE ");
gotoxy(15,6);printf("DE LEURS NOM");
sleep(3);
x=fopen("etudiant.dat","r");
fread(&e,sizeof(etudiant),1,x);
do{
t[k]=e ;
fread(&e,sizeof(etudiant),1,x);
k++;
} while (!feof(x));
fclose(x);
for(i=0;i<k;i++){
for (j=i+1;j<k;j++){
if (strcmp(t[i].nom,t[j].nom)>0){
e=t[i];
t[i]=t[j];
t[j]=e;
}
}
clrscr();
cadre();
affiche();
gotoxy(34,8);
printf("%d",t[i].mat);
gotoxy(34,10);
printf("%s",t[i].nom);
gotoxy(34,12);
printf("%s",t[i].prenom);
gotoxy(34,14);
printf("%2.2f",t[i].moy);
getch();
}
}
/***********************************************************************/
void calcul(FILE *x){
etudiant e;
float m=0 ;
int i=0;
x=fopen("etudiant.dat","r");
fread(&e,sizeof(etudiant),1,x);
while (!feof(x)){
m=m+e.moy ;
i++;
fread(&e,sizeof(etudiant),1,x);
}
if(i!=0){
m=m/i;
}
cadre();
gotoxy(5,7);
printf("La moyenne de la promotion est: %2.2f",m);
getch();
}
/**************************************************************************/
void recherche_nom(FILE*x){
etudiant e;
char nom2[20];
int i=0;
gotoxy(7,4);
printf("donner le nom de l'etudiant a chercher ");
scanf("%s",nom2);
x=fopen("etudiant.dat","r");
while(!feof(x)){
fread(&e,sizeof(etudiant),1,x);
if(strcmp(e.nom,nom2)==0) {
i=1;
affiche();
gotoxy(34,8);
printf("%d",e.mat);
gotoxy(34,10);
printf("%s",e.nom);
gotoxy(34,12);
printf("%s",e.prenom);
gotoxy(34,14);
printf("%2.2f",e.moy);
fread(&e,sizeof(etudiant),1,x);
}
}
if(i==0){
gotoxy(25,10);
printf("CET ETUDIANT N'EXISTE PAS");}
getch();
}
//**********************************************************************
void recherche_mat(FILE*x){
etudiant e; int matr;
int i=0;
gotoxy(7,4);
printf("donner le matricule de l'etudiant a chercher ");
scanf("%d",&matr);
x=fopen("etudiant.dat","r");
while(!feof(x)){
fread(&e,sizeof(etudiant),1,x);
if(e.mat==matr) {
i=1;
affiche();
gotoxy(34,8);
printf("%d",e.mat);
gotoxy(34,10);
printf("%s",e.nom);
gotoxy(34,12);
printf("%s",e.prenom);
gotoxy(34,14);
printf("%2.2f",e.moy);
fread(&e,sizeof(etudiant),1,x);
getch();
}
}
if(i==0)
{gotoxy(25,10);
printf("CET ETUDIANT N'EXISTE PAS");}
getch();
}
//*************************************************************
/*------------------- DESSIN DE CADRE-------------------*/
void cadre(){
int i;
clrscr();
for(i=3;i<78;i++){
gotoxy(i,1);
printf("");
gotoxy(i,22);
printf("*");
gotoxy(i,25);
printf("");}
for (i=0;i<26;i++){
gotoxy(3,i);
printf("");
gotoxy(78,i);
printf(""); }
gotoxy(8,24);
printf("");
}
/************************************************************/
void music(){
int i;
for(i=0;i<7;i++){
sound(100*i);
delay(300*i);
nosound(); }
}
/************************************************************/
void suppression_mat(FILE *x){
FILE *y;
etudiant e;
int mat ,pos;
char re;
cadre();
//sleep(2);
//clrscr();
gotoxy(6,4);
printf("Donnez la matricule de l'etudiant a suppremer ?: ");
scanf("%d",&mat);
gotoxy(5,8);
printf("etes vous sur de vouloir supprimer l'etudiant de matricule %d ? o/n",mat);
re=getch();
if(re=='n')goto not_del;
y=fopen("etud.dat","w");
x=fopen("etudiant.dat","r");
// i=0;
while(!feof(x)){
fread(&e,sizeof(etudiant),1,x);
if(e.mat!=mat) {
//i++;
fwrite(&e,sizeof(etudiant),1,y);
}
}
fclose(x);
fclose(y);
x=fopen("etudiant.dat","w");
y=fopen("etud.dat","r");
while(!feof(y)){
fread(&e,sizeof(etudiant),1,y);
fwrite(&e,sizeof(etudiant),1,x);
}
fclose(x);
fclose(y);
not_del:
}
Sources du même auteur
Sources de la même categorie
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
Copie de fichiers de nom long avec Visual C++ sous Windows98 [ par ABT ]
Salut, Je développe une application avec Visual C++, l'une de ses est de copier des fichiers à partir d'un répertoire vers un autre. J'utilise pour ce
Question simple [ par SysBreak ]
Salut, j'ai Borland C++ 5 v.pro et j'aimerais savoir dans quel répertoire je dois enregistrer mes fichiers sources créés ? Pour les projets j'ai bien
Comment afficher la liste des fichiers dans le composant List View [ par kanimana ]
Bonjour Svp, indiquez moi la fonction qui permettera d'afficher les fichier contenu dans un répertoire dans le composant ListView, avec les détails
pb de base de donnee en C [ par tequ13 ]
j'aimerais savoir comment faire pour charger des fichiers (*.txt) a l'ouverture d'un programme pour ensuite les comparer et repérer les doublons pour
c koi les fichiers h? [ par etmerde ]
je suis débutant(mais alors là, plus nul que ça tu trouves pas), et j'ai vu dans les codes c++ des trucs du genre include (machinchose.h) ou un truc d
problèmes liens entre fichiers C et C++ dans un projet Visual C++ 6.0 [ par nico ]
J'ai récupéré un projet contenant des fichiers écrits en C. Le fichier "principal" de ce projet également écrit en C fait appel à des fonctions se tro
Les fichiers téléchargeables [ par Fantoooom ]
Salut,J'ai téléchargé plusieurs codes sources avec leur fichiers, mais il manque toujours un fichier .h dans les fichiers recu au téléchargement et il
Les fichiers .h ou .hpp [ par Fantoooom ]
Salut,Je ne sais pas comment savoir quelle fonction se trouve dans quelle fichier ???Quelqu'un pourrait me dire où il est possible que je trouve un ge
Problème pour lire les fichiers audio dans un programme C++ [ par Nicolas ]
Pour un projet C++ (linéaire),il souhaiterais réalisé une bibliothèque musical(.mp3, .wav). J'aurais besoin pour ca de lire les fichiers audio mais je
SDK [ par ~~ ]
Je cherche les fichiers necessaires à la compilation d'un projet utilisant DirectX.Ces fichiers sont-ils présents dans le SDK de DirectC pour c++?Si n
|
Derniers Blogs
SESSION SILVERLIGHT 5 3D : SLIDES ET DEMOSSESSION SILVERLIGHT 5 3D : SLIDES ET DEMOS par Groc
Durant les techdays, j'ai eu le plaisir d'animer une session sur Silverlight 5 et la 3D avec Simon Ferquel. Comme promis, voici nos slides et mes démos (celles avec le viper BSG) ici et là. Pour mémoire, les démos utilisent toutes le viper BSG...
Cliquez pour lire la suite de l'article par Groc [TECHDAYS 2012] SESSION WEBMATRIX 2 : LE COUTEAU SUISSE GRATUIT POUR VOS DéVELOPPEMENTS WEB - SLIDES[TECHDAYS 2012] SESSION WEBMATRIX 2 : LE COUTEAU SUISSE GRATUIT POUR VOS DéVELOPPEMENTS WEB - SLIDES par gpommier
Suite à la session que j'ai présenté sur WebMatrix 2, vous pouvez trouver les slides ici, ainsi que les démos en packages nuget : démos1 et démos2 J'en profite pour remercier chaleureusement tous ceux qui sont venus très nombreux à cette sess...
Cliquez pour lire la suite de l'article par gpommier [SHAREPOINT] LES SESSIONS TECHDAYS 2012.[SHAREPOINT] LES SESSIONS TECHDAYS 2012. par Patrick Guimonet
Voici donc pour ceux qui n'ont pas pu venir, ou ceux qui n'ont pas pu toutes les suivre la liste des sessions SharePoint aux TechDays 2012, que je mettrais à jour dès que les liens des vidéo seront disponibles. Ou ici : http...
Cliquez pour lire la suite de l'article par Patrick Guimonet TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3 par ROMELARD Fabrice
Speaker: Bernard Ourghanlian Cette session est comme chaque jour transmise en live par BrainSonic, et j'ai donc suivi cette troisième pleinière par ce moyen sur mon iPad . Elle est dédiée comme chaque année à la mise en perspective de l'é...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice MISHRA READER : UN LECTEUR RSS TRèS ZUNE STYLE EN OPEN SOURCE !MISHRA READER : UN LECTEUR RSS TRèS ZUNE STYLE EN OPEN SOURCE ! par Vko
Hier durant une session dédiée aux Techdays 2012, j'ai eu le plaisir d'annoncer la sortie de la Béta 2 de Mishra Reader. C'est quoi ? Pour les utilisateurs, c'est une vraie expérience de lecture de flux RSS sur Windows. Rien à voir avec les produit...
Cliquez pour lire la suite de l'article par Vko
Logiciels
Tribler (2012)TRIBLER (2012)Tribler est un client pair à pair (P2P/Peer-to-Peer) open source avec la capacité de regarder des... Cliquez pour télécharger Tribler OneSwarm (2012)ONESWARM (2012)Le peer-to-peer qui protège votre vie privée, c'est OneSwarm.
Ce logiciel de peer-to-peer crypté... Cliquez pour télécharger OneSwarm PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Easy-Planning (1.0.0.1)EASY-PLANNING (1.0.0.1)Basé sur les mêmes principes que MyPlanning, Easy-Planning permet de créer des plannings sous la ... Cliquez pour télécharger Easy-Planning
|