1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
| *******************************************************
#include <cstdlib>
#include <iostream>
#include<stdio.h>
#include<string.h>
char moyenne (char* a,char* b)
{
FILE *fpt;
char c;
char* s1="";
char* s2="";
char* s3="";
char* s4="";
fpt= fopen("etudiant.dat","r");
if(fpt == NULL)
{
printf("Impossible d'ouvrir le fichier %s\n");
exit(1);
}
while (!feof(fpt))
{
c=getc(fpt);
while(c!='\t')
{s4="c";
strcat(s1,s4);
}
c=getc(fpt);
while (c=='') c=getc(fpt);
while((c=getc(fpt)!='/t'))
{
s4="c";
strcat(s2,s4);
}
c=getc(fpt);
while(c='') c=getc(fpt);
while((c=getc(fpt)!='/t'))
{
s4="c";
strcat(s3,s4);
}
if (strcmp(s1,a)==0)
{
if (strcmp(s2,b)==0)
{printf("la moyenne de l'etudiant est:/t%s",s3);
break;}
}
c=getc(fpt);
}
}
int main()
{
char* s1;
char* s2;
printf ("veuillez saisir le nom de l'etudiant ");
scanf("%s",s1);
printf ("veuillez saisir le prenom de l'etudiant ");
scanf("%s",s2);
system("PAUSE");
moyenne(s1,s2);
return EXIT_SUCCESS;
}
********************************************************** |
Partager