All pastes #526214 Raw Edit

Anonymous

public text v1 · immutable
#526214 ·published 2007-05-31 18:32 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];
	float kmv;
	float kma;
}deplacement;
void ajouterautomobiliste();
deplacement ajouterdeplacement();
int main()
{
deplacement d;
printf("lol\n");
ajouterautomobiliste();
d=ajouterdeplacement();
return 0;
printf("%s\n",d.nomd);
}

void ajouterautomobiliste()
{
FILE *fa;
automobiliste p;
char choix;
printf("\n\n\t\t\tEntrer un automobiliste oui(o)/non(n): ");
		scanf("%c",&choix);
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 choix;
printf("\n\n\t\t\tEntrer un deplacement oui(o)/non(n): ");
		scanf("%c",&choix);
if((choix=='o')||(choix=='O'))
   if ((fd = fopen("/root/Desktop/test/automo.txt", "a+"))==NULL)
   {
      printf("Cannot open file \n");
   }
   else
   {
      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("%f",&s.kmv);
      fprintf(fd,"\t\t%f",s.kmv);
      printf("le Nombre de KM sur autoroute :");
      scanf("%f",&s.kma);
      fprintf(fd,"\t\t%f",s.kma);
      fputc('\n',fd);
      return(s);
      fclose(fd);
   }
}