Advertisement
Guest User

Untitled

a guest
May 27th, 2015
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.29 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <windows.h>
  5.  
  6.  
  7. int users_struct_nmb, cars_struct_nmb, hire_struct_nmb, cost_struct_nmb; // ilosc wpisow do tablicy struktury
  8. struct users
  9. {
  10.     char id[5];
  11.     char name[50];
  12.     char lastname[50];
  13.     char birth_date[11];
  14.     char pesel[14];
  15.     char passport_nmb[20];
  16.     char home_adress[50];
  17.     char phone_nmb[15];
  18. }person[2];
  19.  
  20. struct cars
  21. {
  22.     char id[5];
  23.     char registration_nmb[10];
  24.     char model[20];
  25.     char brand[20];
  26.     char class[5];
  27.     char next_inspection[11];
  28.     char expiry_of_insurance[11];
  29. }car[100];
  30.  
  31. struct hire
  32. {
  33.     char id[5];
  34.     char customer_id[5];
  35.     char car_id[5];
  36.     char hire_date[11];
  37.     char return_date[11];
  38.     char condition[20];
  39. }rental[100];
  40.  
  41. struct cost
  42. {
  43.     char id[5];
  44.     char class[5];
  45.     char price[10];
  46. }price[100];
  47.  
  48. void clean()
  49. {
  50.     system( "cls" );
  51. }
  52. void add_client()
  53. {
  54.     clean();
  55.     int x;// wyjebac nie potrzebne
  56.     int i;
  57.     printf( "Dodawanie klienta\n\n");
  58.     FILE *file; // Zapis z srednikami, pomiędzy srednikami są przypadkowe wartosci
  59.     file=fopen("Klienci.txt","w");
  60.     for(i=0;i<=users_struct_nmb;i++)// to jest zle, ale zapisuje sredniki
  61.             {
  62.  
  63.             printf("Podaj Id: ");
  64.             scanf("%s",person[i].id);
  65.             printf("Podaj Imie: ");
  66.             scanf("%s",person[i].name);
  67.             printf("Podaj Nazwisko: ");
  68.             scanf("%s",person[i].lastname);
  69.             printf("Podaj Date Urodzenia: ");
  70.             scanf("%s",person[i].birth_date);
  71.             printf("Podaj Pesel: ");
  72.             scanf("%s",person[i].pesel);
  73.             printf("Podaj Numer Paszportu: ");
  74.             scanf("%s",person[i].passport_nmb);
  75.             printf("Podaj Adres Zamieszkania: ");
  76.             scanf("%s",person[i].home_adress);
  77.             printf("Podaj Numer Telefonu: ");
  78.             scanf("%s",person[i].phone_nmb);
  79.             }
  80.     fprintf(file,"%s;%s;%s;%s;%s;%s;%s;%s;\n",
  81.                             person[i].id, person[i].name, person[i].lastname,  person[i].birth_date,
  82.                             person[i].pesel, person[i].passport_nmb, person[i].home_adress, person[i].phone_nmb);
  83.     fclose(file);
  84.     printf( "0.Wstecz\n" ); // wyjebac nie potrzebne
  85.     scanf("%d",&x);// wyjebac nie potrzebne
  86. }
  87. int main() {
  88.     add_client();
  89.     return 0;
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement