Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- int main(){
- FILE *ficha;
- FILE *fcoches;
- FILE *fmotos;
- FILE *fcamiones;
- FILE *fcuadrimotos;
- int year;
- char nombre[2],apellido[20], marca[20], tipo[20];
- ficha=fopen("Dakar.txt", "r");
- fcoches=fopen("coches.txt", "w");
- fmotos=fopen("motos.txt", "w");
- fcamiones=fopen("camiones.txt", "w");
- fcuadrimotos=fopen("cuadrimotos.txt", "w");
- while (!feof(ficha)){
- fscanf (ficha, "%d%s%s%s%s", &year,nombre,apellido,marca,tipo);
- if (strcmp(tipo,"Coches")==0)
- fprintf (fcoches,"%d %s %s %s %s\n",year,nombre,apellido,marca,tipo );
- else if (strcmp(tipo,"Motos")==0)
- fprintf (fmotos,"%d %s %s %s %s\n",year,nombre,apellido,marca,tipo );
- else if (strcmp(tipo,"Camiones")==0)
- fprintf (fcamiones,"%d %s %s %s %s\n",year,nombre,apellido,marca,tipo );
- else if (strcmp(tipo,"Cuadrimotos")==0)
- fprintf (fcuadrimotos,"%d %s %s %s %s\n",year,nombre,apellido,marca,tipo );
- }
- fclose(ficha);
- fclose(fmotos);
- fclose(fcoches);
- fclose(fcamiones);
- fclose(fcuadrimotos);
- printf ("Listo\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement