c - Is it possible to pass arguments from argv to a function called with dlsym? -


this assignment c class, it's supposed exercise in dynamic libraries. figured out how of it, stuck on last step.

basically, given function specified file, can call using dlsym. however, number , types of arguments can vary function function. given shortened function signature , arguments through argv[]. shortened function signature function printf('hello: %s, %d, %f', abc, 10, 12.4) this:

vccid { short void func(char *, char *, int, double) }

for example, if need call described printf function, argv this:

[ ],[ name of file function located ],[ name of function ],[ vccid ],[ 'hello: %s, %d, %f' ],[ abc ],[ 10 ],[ 12.4 ]

i use dlopen , dlsym function itself

typedef void *(*arbitrary1)(); ... int main(int argc, const char * argv[]) { arbitrary1 f1; void *handle = dlopen(argv[1], rtld_lazy); *(void**)f1 = dlsym(handle, argv[2]); ... } 

now, question this: there way pass arguments argv function call? end result

f1('hello: %s %d %f', abc, 10, 12.4); 

thank in advance help


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -