task4.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include <stdio.h>
  2. #include <dlfcn.h>//функция для открытия библиотеки
  3. struct _person
  4. {
  5. char* surname;
  6. char* name;
  7. char* patronymic;
  8. int age;
  9. struct _person* next;
  10. };
  11. typedef struct _person Person;
  12. typedef Person* People;
  13. typedef void(*sfunDll)(People);
  14. typedef void(*wtfunDll)(People, char*);
  15. typedef double(*afunDll)(People);
  16. typedef People(*wfunDll)(char*);
  17. typedef People(*shfunDll)(People,char*);
  18. int main()
  19. {
  20. char* dataPath = "файл.csv";
  21. char* answerPath = "a.csv";
  22. void* dll = dlopen("./libdll.so",RTLD_NOW);//открываем библиотеку
  23. wfunDll Pread = dlsym(dll, "readFile");
  24. wtfunDll Pwrite = dlsym(dll, "writePeople");
  25. sfunDll Pshow = dlsym(dll,"showPeople");
  26. shfunDll Psearch = dlsym(dll,"searchPeople");
  27. afunDll Paverage = dlsym(dll, "averagePeople");
  28. People society = Pread(dataPath);
  29. Pshow(society);
  30. printf("\n");
  31. People newSociety = Psearch(society,"Иванов");
  32. Pshow(newSociety);
  33. printf("\n2: %f many:%f\n", Paverage(newSociety), Paverage(society));
  34. Pwrite(newSociety, answerPath);
  35. return 0;
  36. }