Données sans types en C

Fermé
Nanel - 28 juin 2010 à 23:34
Char Snipeur Messages postés 9813 Date d'inscription vendredi 23 avril 2004 Statut Contributeur Dernière intervention 3 octobre 2023 - 29 juin 2010 à 09:32
Bonsoir à tous,
j'ai un problème pour finaliser mon code en C. Il s'agit d'un programme qui gère trois fichier un qui contient les enregistrements d'étudiants, un qui contient les matieres et un autre les notes. J'ai fais de tel sorte qu'en saisissant le numero d'inscription de l'étudiant, on a ses coordonnées, puis il faut entrer ses notes par rapport au fichier des matieres qui se charge aussi. Tout ça je crois que j'l'ai gérer.
J'ai aussi fait le calcul de la moyenne automatiquement. Seulement le programme ne s'exécute pas et les message d'erreur est le suivant :

"1. [Warning] parameter names (without types) in function declaration
2. [Warning] data definition has no type or storage class "


Pour être plus explicite, voici le code :

#include<stdio.h>
#include<stdlib.h>
struct notes
{
int numins, codemat, note;
};
struct Etudiant
{
int numin, code;
char prenom[50], nom[40], clas[20], decision[8];
float moygen;
};
struct Matiere
{
int codem, coeff;
char libelle[20];
};
int main ()
{
FILE *note=NULL, *fich=NULL, *matieres=NULL;
struct Matiere mati;
struct Etudiant vetudiant;
struct notes not;
char rep;
int i, j, k, taille, Tcoeff;
float NotCoef, Tnotes;
fich = fopen("etudiants.don","w");
i=0;
rep=' ';
while(toupper(rep)!='N')
{
i++;
vetudiant.numin=i;
vetudiant.moygen=0;
strcpy(vetudiant.decision," ");
printf("Entrez le prenom d'un etudiant : ");
scanf("%s",&vetudiant.prenom);
printf("Entrez son nom : ");
scanf("%s",&vetudiant.nom);
printf("Entrez sa classe : ");
scanf("%s",&vetudiant.clas);
printf("Entrez le code de la classe : ");
scanf("%d",&vetudiant.code);
fwrite(&vetudiant,sizeof(vetudiant),1,fich);
printf("Avez vous un autre etudiant a enregistrer?\n\t(O/N)\nReponse : ");
rep=getch();
}
fclose(fich);
matieres=fopen("matieres.dat","w");
Tcoeff=0;
for(j=1;j<=2;j++)
{
mati.codem=j;
printf("Entrez le libelle de la matiere %d : ", j);
scanf("%s",&mati.libelle);
printf("Entrez le coefficient de la matiere : ");
do
{
scanf("%d",&mati.coeff);
}
while((mati.coeff<0)||(mati.coeff>20));
Tcoeff=+mati.coeff;
printf("Total coefficient : %d", Tcoeff);
fwrite(&mati,sizeof(mati),1,matieres);
}
fclose(matieres);
matieres=fopen("matieres.dat","r");
if(matieres==NULL) printf("Echec de l'ouverture du fichier\n");
else
{
printf("\n\n\t\tLISTE DES MATIERES\n\n");
printf("\nNumeros\t\tLibelles\t\tCoefficients\n\n");
fread(&mati,sizeof(mati),1,matieres);
while(!feof(matieres))
{
printf(" %d\t %s\t\t %d\n", mati.codem, mati.libelle, mati.coeff);
fread(&mati,sizeof(mati),1,matieres);
}
}
fich=fopen("etudiants.don","r");
if(fich==NULL) printf("Echec lors de l'ouverture");
else
{
printf("\n\n\t\tLISTE DES ETUDIANTS\t\t\n");
printf("\n\nNum I\t Prenoms\t Noms\t Classes\t Codes de classe\t Moyenne\t Decision\n");
fread(&vetudiant,sizeof(vetudiant),1,fich);
while(!feof(fich))
{
printf("%d \t %s\t %s\t %s\t %d\t %.2f\t '%s'\n", vetudiant.numin, vetudiant.prenom, vetudiant.nom, vetudiant.clas, vetudiant.code, vetudiant.moygen, vetudiant.decision);
fread(&vetudiant,sizeof(vetudiant),1,fich);
}
}
note=fopen("lesnotes.don","r+");
printf("Entrez le numero d'inscription d'un etudiant : ");
do
{
scanf("%d",¬.numins);
}
while((not.numins+1)==vetudiant.numin);/*not.numins+1 pour qu'il compte à partir de 1*/
printf("Le numero d'inscription : %d\nNom : %s\nPrenom: %s\n\n", vetudiant.numin, vetudiant.nom, vetudiant.prenom);
Tnotes=0;
for(k=1;k<=2;k++);
{
printf("Entrez le code d'une matiere : ");
do
{
scanf("%d",not.codemat);
}
while((not.codemat+1)==mati.codem);
printf("Matieres : %s", mati.libelle);
printf("Entrez la note de l'etudiant : ");
do
{
scanf("%f",¬.note);
}
while(not.note<0||not.note>20);
NotCoef=not.note*mati.coeff;
printf("NotCoef : %f", NotCoef);
Tnotes=+NotCoef;
printf("Tnotes: %.2f", Tnotes);
printf("Total coefficient : %d", Tcoeff);
}
vetudiant.moygen=Tnotes/Tcoeff;
printf("Sa moyenne est : %.2f", vetudiant.moygen);
}
fclose(matieres);
fclose(note);
fclose(fich);
system("pause");
return 0;
}

Merci à vous!

1 réponse

Char Snipeur Messages postés 9813 Date d'inscription vendredi 23 avril 2004 Statut Contributeur Dernière intervention 3 octobre 2023 1 298
29 juin 2010 à 09:32
un warning n'empeche pas de compiler et exécuter.
Montre nous la ligne en cause.
0