SHARE
TWEET

Struktura

a guest Jan 28th, 2020 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <ctype.h>
  5. typedef struct student {
  6.     char ime[100];
  7.     char prezime[100];
  8.     int godiste;
  9. }STUDENT;
  10.  
  11. void unosNizaStudenata(STUDENT nizStudenata[], int *brStudenata);
  12. //STUDENT unosUStrukturu2(STUDENT *stud); ?????????
  13. void ispisiStudente(STUDENT nizStudenata[], int brStudenata);
  14. STUDENT unosStudenata();
  15.  
  16. int meni() {
  17.     printf("\n\n\
  18.     =======\n\
  19.       MENI \n\
  20.     =======\n\
  21.    1)Ubaci studenta\n\
  22.     2)Prikazi listu\n\
  23.     3)Sortiraj po prezimenu\n\
  24.     0)Kraj rada \n\n\
  25.     Vas izbor je: ");
  26. }
  27.  
  28. int main() {
  29.     //STUDENT student1;
  30.     STUDENT nizStudenata[100];
  31.     int brStudenata=0;
  32.     unosNizaStudenata(nizStudenata, &brStudenata);
  33.     ispisiStudente(nizStudenata, brStudenata);
  34.     //student1 = unosStudenata();
  35.     //printf("Ime studenta je: %s\n", student1.ime);
  36.     //printf("Prezime studenta je: %s\n", student1.prezime);
  37.     //printf("Godiste studenta je: %d\n", student1.godiste);
  38.     system("pause");
  39.     return 0;
  40. }
  41. STUDENT unosStudenata() {
  42.     STUDENT novi;
  43.     printf("Unesi ime: ");
  44.     gets(novi.ime);
  45.     printf("Unesi prezime: ");
  46.     gets(novi.prezime);
  47.     printf("Unesi godiste: ");
  48.     scanf("%d", &novi.godiste);
  49.     getchar();
  50.     return novi;
  51. }
  52. void unosNizaStudenata(STUDENT nizStudenata[], int *brStudenata) {
  53.     printf("Koliko studenata unosis: ");
  54.     scanf("%d", brStudenata);
  55.     getchar();
  56.     int i;
  57.     for (i = 0; i < *brStudenata; i++) {
  58.         nizStudenata[i] = unosStudenata();
  59.         //nizStudenata[i] = unosUStrukturu2(&nizStudenata,brStudenata); Zasto ovo ne moze?
  60.         //(*brStudenata)++;
  61.     }
  62. }
  63. void ispisiStudente(STUDENT nizStudenata[], int brStudenata) {
  64.     int i;
  65.     for (i = 0; i < brStudenata; i++) {
  66.         printf("%s %s %d \n", nizStudenata[i].ime, nizStudenata[i].prezime, nizStudenata[i].godiste);
  67.     }
  68. }
  69. STUDENT unosUStrukturu2(STUDENT *stud,int brStudenata) {
  70.     int i;
  71.     for (i = 0; i < brStudenata; i++) {
  72.         printf("Unesi ime: ");
  73.         gets(stud->ime);
  74.         printf("Unesi prezime: ");
  75.         gets(stud->prezime);
  76.         printf("Unesi godiste: ");
  77.         scanf("%d", stud->godiste);
  78.         getchar();
  79.     }
  80. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top