Advertisement
Adijata

Imenik

Jul 20th, 2014
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.40 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <math.h>
  5. struct Osoba
  6. {
  7.     char ime[15];
  8.     char prezime[15];
  9.     int telefon;
  10. };
  11.  
  12. int main()
  13. {
  14.     struct Osoba o;
  15.     struct Osoba osobe[200];
  16.     int vel=0;
  17.     int izbor;
  18.  
  19.     printf("Pritisnite 1 za unos, 2 za ispis i 0 za izlaz:\n");
  20.     scanf("%d", &izbor);
  21.     while (izbor != 0)
  22.     {
  23.  
  24.     switch(izbor) // ovaj si switch skroz bila zeznula
  25.         {
  26.  
  27.              case 1:
  28.             printf("Unesite ime osobe:\n");
  29.             scanf("%s", &o.ime); //%s nesto ko string mozes unijeit samo jednu rijec da en koristis funkciju unosa
  30.             printf("Unesite prezime osobe:\n");
  31.             scanf("%s", &o.prezime);
  32.             printf("Unesite broj telefona osobe:\n");
  33.             scanf("%d", &o.telefon);
  34.  
  35.             osobe[vel++]=o;
  36.  
  37.  
  38.             break;
  39.             int i;
  40.              case 2:
  41.                  for(i=0; i<vel; i++)
  42.                  {
  43.                      printf("Ispis %d. osobe:\n", i+1);
  44.                      printf("Ime: %s\n", osobe[i].ime);
  45.                      printf("Prezime: %s\n", osobe[i].prezime);
  46.                      printf("Broj: %d\n", osobe[i].telefon);
  47.                      printf("\n");
  48.                  }
  49.         }
  50.  
  51.  
  52.             if(izbor==0) break;
  53.         printf("\nPritisnite 1 za unos, 2 za ispis i 0 za izlaz:\n");
  54.         scanf("%d", &izbor);
  55.  
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement