Advertisement
lukasd

zadanie 5 kolokwium 3

Feb 11th, 2018
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.77 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdbool.h>
  3. #include <string.h>
  4.  
  5. typedef struct
  6. {
  7.    unsigned char id, idm, ido;
  8.    char name [50];
  9. } Person;
  10.  
  11. void check(FILE *fp, char str[])
  12. {
  13.    int size;
  14.    fseek(fp,0,SEEK_END);
  15.    size=ftell(fp)/sizeof(Person);
  16.    Person arr[size];
  17.    fseek(fp,0,SEEK_SET); // lub rewind(fp);
  18.  
  19.    fread(arr, sizeof(Person), size, fp); // gdzie, rozmiar poj elem, ile elementow, skad
  20.    bool found=true;
  21.    char *pch=str;
  22.    for(int i=0; i<size; i++)
  23.    {
  24.       for(int j=0; i<size; i++)
  25.          if(arr[i].id=arr[j].idm || arr[i].id==arr[j].ido)
  26.             found=false;
  27.       if(found)
  28.       {
  29.          memcpy(pch, arr[i].id, 50);  // do czego, z czego, ile
  30.          pch+=50;
  31.          *pch=",";
  32.          pch=+1;
  33.       }
  34.    }
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement