Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum. Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !

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:
 }

Commentaires et avis

signaler à un administrateur
Commentaire de rrk275 le 22/03/2007 18:33:35

Je pense que c'est le moment de lacher ta chère console... ou de faire de l'algo ! ^^

Louis

signaler à un administrateur
Commentaire de PCBill le 22/03/2007 20:55:52

Bonsoir Monsieur PRK275 ;
En fait, je n'arrive pas à cerner le sujet (sens) de votre intervention.
Veuillez m'expliquer !
Merci.

signaler à un administrateur
Commentaire de rrk275 le 24/03/2007 12:31:14

Pas mal de gens postent leurs petits exos, or là il s'agit d'un projet plus important, par sa taille et au regard de cette source, on voit clairement que tu la maitrise bien, gotoxy, printf, sound , delay et on voit que tu maitrise plutot pas mal le C, et surtout tu n'as pas l'air d'être débordé par le fait qu'il y ait beaucoup de code à faire, donc je te suggère de te lancer dans des vrais interfaces graphiques car tu sembles aimer la soigner dans cette source;..

Louis

signaler à un administrateur
Commentaire de PCBill le 24/03/2007 15:15:08

Monsieur PRK275 ;
Merci pour vos compliments ; j'aurais bien aimé mâter ce que vous venez me conseiller ce qui fait toute aide de votre part serait précieuse pour moi -vous pouvez, à titre d'exemple, m'orienter vers des sites traitant de ce sujet -sites anglophones compris-
Je serais heureux de recevoir une orientation dans ce sens.

Une fois encore , je vous remercie.

Ajouter un commentaire

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


Nos sponsors

Sondage...

CalendriCode

Juillet 2009
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
2728293031  

Consulter la suite du CalendriCode

Téléchargements

Logiciels à télécharger sur le même thème :

Comparez les prix Nouvelle version

Photothèque Nouveau !



Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés
Temps d'éxécution de la page : 0,905 sec

Google Coop CodeS-SourceS Google Coop CodeS-SourceS


Certaines images présentes sur le site (notament certains avatars) sont issues des collections IconShock, donc si vous souhaitez utiliser ces icons vous devez les acheter, ne les copiez pas et ne utilisez pas dans vos sites et applications sans les avoir commandé.