Compiled Function in a file

Today I am given an assignment to find the zeroes of a function using Newton-Raphson method. Till now, the input I gave to a program was data. But now the function (whose zeroes are to be calculated) is also an input.

Is there a way where I can compile and build a function into a file and during execution of my program open the file and run the machine-language code in it and get the return value?
No, here is no straight way (like in scripting languages - JS, PHP or Python). So you are to use some math expression parsing - and if you are not going to do this on your own, you are to find any suitable library.

Though you'd better read your assignment once more. Perhaps you are to use function of some specific type changing only its coefficients?

It is suspicious that you are required to implement parsing of arbitrary math expression...
Is there a way where I can compile and build a function into a file and during execution of my program open the file and run the machine-language code in it and get the return value?
Yes. But the compiled code goes into a library.

Generally, it's called a shared library. Windows call it a dynamically linked library.
@rodiongork
The assignment doesn't require me to decide the function at runtime. But I thought it would be cool if it was possible. The assignment problem just gave me the idea of doing this.

@kbw
Thanks for the help. I searched the net and found the windows API functions LoadLibrary(LPCTSTR) and GetProcAddress(HMODULE,LPCSTR). I'm going to try these soon.
Topic archived. No new replies allowed.