CARVIEW |
Select Language
HTTP/2 302
server: nginx
date: Sun, 24 Aug 2025 10:41:30 GMT
content-type: text/plain; charset=utf-8
content-length: 0
x-archive-redirect-reason: found capture at 20080502121955
location: https://web.archive.org/web/20080502121955/https://www.daniweb.com/code/snippet857.html
server-timing: captures_list;dur=0.942876, exclusion.robots;dur=0.031752, exclusion.robots.policy;dur=0.015195, esindex;dur=0.015891, cdx.remote;dur=20.859035, LoadShardBlock;dur=147.619008, PetaboxLoader3.datanode;dur=43.419578, PetaboxLoader3.resolve;dur=71.342381
x-app-server: wwwb-app204
x-ts: 302
x-tr: 222
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
set-cookie: wb-p-SERVER=wwwb-app204; path=/
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
HTTP/2 200
server: nginx
date: Sun, 24 Aug 2025 10:41:30 GMT
content-type: text/html; charset=utf-8
x-archive-orig-date: Fri, 02 May 2008 12:19:54 GMT
x-archive-orig-server: Apache/2.2
x-archive-orig-x-powered-by: PHP/5.1.6
x-archive-orig-set-cookie: bblastactivity=0; expires=Sat, 02-May-2009 12:19:54 GMT; path=/; domain=.daniweb.com
x-archive-orig-cache-control: private
x-archive-orig-pragma: private
x-archive-orig-connection: close
x-archive-guessed-content-type: text/html
x-archive-guessed-charset: utf-8
memento-datetime: Fri, 02 May 2008 12:19:55 GMT
link: ; rel="original", ; rel="timemap"; type="application/link-format", ; rel="timegate", ; rel="first memento"; datetime="Fri, 02 May 2008 12:19:55 GMT", ; rel="memento"; datetime="Fri, 02 May 2008 12:19:55 GMT", ; rel="next memento"; datetime="Fri, 09 May 2008 04:38:17 GMT", ; rel="last memento"; datetime="Wed, 24 Sep 2008 14:25:18 GMT"
content-security-policy: default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: archive.org web.archive.org web-static.archive.org wayback-api.archive.org athena.archive.org analytics.archive.org pragma.archivelab.org wwwb-events.archive.org
x-archive-src: 52_3_20080502065046_crawl108-c/52_3_20080502121939_crawl104.arc.gz
server-timing: captures_list;dur=0.666862, exclusion.robots;dur=0.024783, exclusion.robots.policy;dur=0.011923, esindex;dur=0.011907, cdx.remote;dur=6.112968, LoadShardBlock;dur=379.743579, PetaboxLoader3.resolve;dur=230.852803, PetaboxLoader3.datanode;dur=85.888794, load_resource;dur=70.086232
x-app-server: wwwb-app204
x-ts: 200
x-tr: 612
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=1
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
content-encoding: gzip
Student data bases management using files in C - c
Student data bases management using files in C
•
•
•
•

What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 322,721 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,042 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser:
Hi from Begueradj,
This program written in Turbo C simulates a student data bases using files.
Basic operations such as seeking for a given student, deleting, adding and sorting are implemented here.
Feel free to give me your points of view.
Thanks, Begueradj.
This program written in Turbo C simulates a student data bases using files.
Basic operations such as seeking for a given student, deleting, adding and sorting are implemented here.
Feel free to give me your points of view.
Thanks, Begueradj.
// 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: }
Post Comment
•
•
•
•
DaniWeb Marketplace (Sponsored Links)
- Today's Posts
- Unanswered Threads
Related Features
DANIWEB FEATURE INDEX
ADVERTISEMENT
STATISTICS