avukas

imeiprezime

Feb 8th, 2014
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #define vel 100
  4.  
  5. struct osoba
  6. {
  7. char ime[15];
  8. char prezime[15];
  9. int broj;
  10. };
  11.  
  12. struct osoba unososobe()
  13. {
  14. struct osoba osoba;
  15. printf("Unesite ime osobe:\n");
  16. scanf("%c", &osoba.ime );
  17. printf("Unesite prezime osobe:\n");
  18. scanf("%c", &osoba.prezime);
  19. printf("Unesite broj telefona:\n");
  20. scanf("%d", &osoba.broj);
  21.  
  22. }
  23. void ispisosobe(struct osoba osoba)
  24. {
  25. printf ("%s %s - telefon: %09d",osoba.ime, osoba.prezime, osoba.broj );
  26. }
  27.  
  28. int meni()
  29. {
  30. int izbor;
  31. printf("Pritisnite 1 z UNOS, 2 za ISPIS, 0 za IZLAZ: ");
  32. scanf("%d", &izbor);
  33. return izbor;
  34. }
  35.  
  36. int main()
  37. {
  38. struct osoba osobe[vel];
  39. int i=0, izbor, broj=0;
  40. do {
  41. izbor=meni();
  42.  
  43. switch(izbor) {
  44. case 1:
  45. if (broj< vel)
  46. {
  47. osobe[broj]=unososobe();
  48. broj ++;
  49. }
  50. else printf("Nije moguce unijeti vise od %d osoba! \n ", vel);
  51. break;
  52.  
  53. case 2:
  54. for (i=0; i<vel; i++)
  55. ispisosobe(osobe[i]);
  56. break;
  57. } }
  58. while(izbor!=0);
  59.  
  60. return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment