Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- short ouvrier_init(char path[],Ouvrier *pOuvrier)
- {
- FILE *pf = fopen(path,"rb");
- short retour = 1,i;
- /*Vérificatioin que le fichier ouvrier existe*/
- if(pf==NULL)
- {
- /*si pas de fichier on le crée*/
- pf = fopen(path,"wb");
- if(pf == NULL)
- {
- printf("Impossible de crée le fichier ouvrier, arret du programme\n");
- retour = 0;
- }
- else/*bidonnage du fichier*/
- {
- pOuvrier->NumRegistre = -1;
- strcpy(pOuvrier->nom," ");
- strcpy(pOuvrier->prenom," ");
- strcpy(pOuvrier->rue," ");
- pOuvrier->codePostal = -1;
- strcpy(pOuvrier->ville," ");
- strcpy(pOuvrier->specialite," ");
- pOuvrier->naissance.jour = -1;
- pOuvrier->naissance.mois = -1;
- pOuvrier->naissance.annee = -1;
- pOuvrier->engagement.jour = -1;
- pOuvrier->engagement.mois = -1;
- pOuvrier->engagement.annee = -1;
- /*écriture dans le fichier*/
- if ( fwrite(pOuvrier,sizeof(Ouvrier),1,pf) != 100)
- {
- printf("Erreur lors du bidonnage du fichier\n");
- retour = 0;
- }
- else
- {
- printf("Bidonnage du fichier %s effectue\n",path);
- }
- }
- }
- return retour;
- }
Advertisement
Add Comment
Please, Sign In to add comment