Advertisement
anechka_ne_plach

Untitled

Feb 21st, 2022
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.60 KB | None | 0 0
  1.    1   │ #include <dlfcn.h>
  2.    2   │ #include <stdlib.h>
  3.    3   │ #include <stdio.h>
  4.    4   │
  5.    5   │ int main(int argc, char* argv[]) {
  6.    6   │     void* handle = dlopen("/lib/libm.so.6", RTLD_LAZY);
  7.    7   │     if (!handle) abort();
  8.    8   │
  9.    9   │     void* ptr = dlsym(handle, argv[1]);
  10.   10   │     if (!ptr) abort();
  11.   11   │     typedef double (*func_t)(double);
  12.   12   │
  13.   13   │     double v;
  14.   14   │     while (scanf("%lf", &v) != EOF) {
  15.   15   │         printf("%.10g\n", ((func_t) ptr)(v));
  16.   16   │     }
  17.   17   │     dlclose(handle);
  18.   18   │ }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement