SHARE
TWEET

Untitled

a guest Feb 18th, 2020 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int ucitaj(struct Grad *gradovi, int n)
  2. {
  3.     int br_gradova = 0, i = 0, j = 0;
  4.     FILE *ulaz = fopen("gradovi.txt", "r");
  5.     char c;
  6.     while(!feof(ulaz)) {
  7.         while(1) {
  8.             c = fgetc(ulaz);
  9.             gradovi[i].naziv[j] = c;
  10.             j++;
  11.             if((c >= '0' && c <= '9') || c == EOF || c == '\n') break;
  12.         }
  13.         gradovi[i].naziv[j - 2] = '\0';
  14.         j = 0;
  15.         fseek(ulaz, -1, SEEK_CUR);
  16.         if(fscanf(ulaz, "%d\n", &gradovi[i].br_stanovnika) == 0) break;
  17.         else i++;
  18.     }
  19.     if(i > n) br_gradova = n;
  20.     else br_gradova = i;
  21.     fclose(ulaz);
  22.     return br_gradova;
  23. }
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