All pastes #526301 Raw Edit

Mine

public text v1 · immutable
#526301 ·published 2007-05-31 19:17 UTC
rendered paste body
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
typedef struct
{
	char nom[40];
	char marque[40];
	char modele[40];
	char type[40];
	char moteur[40];
	char carburant[40];
	float consoville;
	float consoautoroute;
}automobiliste;
typedef struct
{
	char nomd[40];
	char depart[40];
	char arrivee[40];
	int kmv;
	int kma;
}deplacement;
void ajouterautomobiliste();
deplacement ajouterdeplacement();
int main()
{
deplacement d;
printf("-----------------------Fichier Automobilistes--------------\n");
ajouterautomobiliste();
printf("-----------------------Fichier Déplacements--------------\n");
d=ajouterdeplacement();
return 0;
printf("%s\n",d.nomd);

}
void ajouterautomobiliste()
{
FILE *fa;
automobiliste p;
char choix;
fflush(stdin);
printf("\n\n\t\t\tEntrer un automobiliste oui(o)/non(n): ");
fflush(stdin);
scanf("%c",&choix);
fflush(stdin);
if((choix=='o')||(choix=='O'))
  {
    if ((fa = fopen("/root/Desktop/test/automo.txt", "a+"))==NULL)
    {
      printf("Cannot open file \n");
    }
    else 
    {
      printf("Nom automobiliste :");
      scanf("%s",p.nom);
      fprintf(fa,"%s",p.nom);
      printf("la Marque du véhicule :");
      scanf("%s",p.marque);
      fprintf(fa,"\t+%s",p.marque);
      printf("Modéle du véhicule :");      
      scanf("%s",p.modele);
      fprintf(fa,"\t+%s",p.modele);
      printf("type :");
      scanf("%s",p.type);
      fprintf(fa,"\t\t\t\t+%s",p.type);
      printf("type Moteur :");
      scanf("%s",p.moteur);
      fprintf(fa,"\t+%s",p.moteur);
      printf("type du carburant :");
      scanf("%s",p.carburant);
      fprintf(fa,"\t+%s",p.carburant);
      printf("Consommation en ville ( nombre de litres / 100km ):");
      scanf("%f",&p.consoville);
      fprintf(fa,"\t+%f",p.consoville);
      printf("Consommation sur autoroute (nombre de litres / 100km):");
      scanf("%f",&p.consoautoroute);
      fprintf(fa,"\t+%f",p.consoautoroute);
      fputc('\n',fa);
      fclose(fa);
    }
  }
}
deplacement ajouterdeplacement()
{
FILE *fd;
deplacement s;
char choi;
fflush(stdin);
printf("\n\n\t\t\tEntrer un deplacement oui(o)/non(n): ");
fflush(stdin);
scanf("%c",&choi);
fflush(stdin);
if((choi=='o')||(choi=='O'))
       if ((fd = fopen("/root/Desktop/test/automo.txt", "a+"))==NULL)
{
  printf("Cannot open file \n");
}
      printf("Nom automobiliste :");
      scanf("%s",s.nomd);
      fprintf(fd,"%s",s.nomd);
      printf("ville de départ :");
      scanf("%s",s.depart);
      fprintf(fd,"\t\t\t\t%s",s.depart);
      printf("ville d'arivée :");
      scanf("%s",s.arrivee);
      fprintf(fd,"\t\t\t\t%s",s.arrivee);
      printf("le Nombre de KM en ville :");
      scanf("%d",&s.kmv);
      fprintf(fd,"\t\t%d",s.kmv);
      printf("le Nombre de KM sur autoroute :");
      scanf("%d",&s.kma);
      fprintf(fd,"\t\t%d",s.kma);
      fputc('\n',fd);
      return(s);
      fclose(fd);

}