ctest2.c 393 B

1234567891011121314151617181920
  1. #include <dlfcn.h>
  2. #include <string.h>
  3. int main()
  4. {
  5. void *lib;
  6. char *s;
  7. int FromPos, ToPos;
  8. char* (*SubStr)(const char*, int, int);
  9. lib = dlopen("./libsubs.so", RTLD_LAZY);
  10. SubStr = dlsym(lib, "SUBSTR");
  11. s = strdup("Test");
  12. FromPos = 2;
  13. ToPos = 3;
  14. printf("Result from SubStr: '%s'\n", (*SubStr)(s, FromPos, ToPos));
  15. dlclose(lib);
  16. return 0;
  17. }