zoi20

Untitled

Jan 14th, 2014
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.01 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. struct osoba
  4. {
  5.     char ime[15];
  6.     char prezime[15];
  7.     int telefon;
  8. };
  9. struct osoba unos()
  10. {
  11.     struct osoba a;
  12.     int i=0;
  13.     printf("unesite ime: ");
  14.     while(a.ime[i]!=' '||a.ime[i]!='\n')
  15.     {
  16.         a.ime[i]=getchar();
  17.         i++;
  18.     }
  19.     a.ime[i-1]='\0';
  20.  
  21.  
  22.    printf("unesite prezime: ");
  23.     while(a.prezime[i]!=' '||a.prezime[i]!='\n')
  24.     {
  25.         a.prezime[i]=getchar();
  26.         i++;
  27.     }
  28.     a.prezime[i-1]='\0';
  29.  
  30.  
  31.    printf("unesite telefon: ");
  32.         scanf("%d",&a.telefon);
  33.  
  34. return a;
  35. }
  36.  
  37. void ispis()
  38. {
  39.     struct osoba b;
  40.     int i=0;
  41.     while(b.ime[i]!='\0')
  42.     {
  43.         printf("%c",b.ime[i]);
  44.         i++;
  45.     }
  46.      while(b.prezime[i]!='\0')
  47.     {
  48.         printf("%c",b.prezime[i]);
  49.         i++;
  50.     }
  51.     printf("%d",b.telefon);
  52. }
  53.  
  54. int main()
  55. {
  56.     struct osoba neka;
  57.     int b;
  58.     scanf("%d",&b);
  59.    if (b==1) neka=unos();
  60.    else if(b==2) ispis(neka);
  61.    else if (b==0) exit(1);
  62.     return 0;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment