1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- #include <stdio.h>
- #include <dlfcn.h>//функция для открытия библиотеки
- struct _person
- {
- char* surname;
- char* name;
- char* patronymic;
- int age;
- struct _person* next;
- };
- typedef struct _person Person;
- typedef Person* People;
- typedef void(*sfunDll)(People);
- typedef void(*wtfunDll)(People, char*);
- typedef double(*afunDll)(People);
- typedef People(*wfunDll)(char*);
- typedef People(*shfunDll)(People,char*);
- int main()
- {
- char* dataPath = "файл.csv";
- char* answerPath = "a.csv";
- void* dll = dlopen("./libdll.so",RTLD_NOW);//открываем библиотеку
- wfunDll Pread = dlsym(dll, "readFile");
- wtfunDll Pwrite = dlsym(dll, "writePeople");
- sfunDll Pshow = dlsym(dll,"showPeople");
- shfunDll Psearch = dlsym(dll,"searchPeople");
- afunDll Paverage = dlsym(dll, "averagePeople");
- People society = Pread(dataPath);
- Pshow(society);
- printf("\n");
- People newSociety = Psearch(society,"Иванов");
- Pshow(newSociety);
-
- printf("\n2: %f many:%f\n", Paverage(newSociety), Paverage(society));
- Pwrite(newSociety, answerPath);
- return 0;
- }
|