function Name
hi,
I am writing a function that takes the return value of the another
function and gives the status of the function.
if
error("functionName",arguments)
here the function with Name "functionName " is to be executed with the corresponding argunents.But by knowing the function name how can i get the address if that function and how can i execute the function with the arguments.
thanking you
Quoted 4 lines · raja
hi,
I am writing a function that takes the return value of the another
function and gives the status of the function.
if
your question is off-topic for this list, please stop posting these questions.
Suggestion: subscribe to the kernel-newbies list (see www.kernelnewbies.org) instead
Hello raja,
Quoted 8 lines · you
I am writing a function that takes the return value of the another
function and gives the status of the function.
if
error("functionName",arguments)
here the function with Name "functionName " is to be executed with the corresponding argunents.But by knowing the function name how can i get the address if that function and how can i execute the function with the arguments.
A good place to ask C questions is IRC channel #c on IRCNET. Lookup an IRCNET server in your vicinity and try there.
Really good and helpful people are hanging around.
--
Maciej
Quoted 5 lines · --- raja
hi,
I am writing a function that takes the return
value of the another
function and gives the status of the function.
if
Quoted 9 lines
error("functionName",arguments)
here the function with Name "functionName " is to be executed with the
corresponding argunents.But by knowing the function name how can i get
the address if that function and how can i execute the function with the
arguments.
Dude, this is not the right forum for these types of questions. You need to look at some good general texts. I don't know if you can get a copy of Steven's or other general Unix programming text, but that's what would help you the most. Anyway, here's an example for you. The C compiler in general treats a function name as a type of pointer, similar to an array base pointer in that you cannot modify it, but you can de-reference it.
/* Crude demo program for calling a function
* by indirect means and supplying arguments. *
* Yes, it's GPL. :-)
*/
#include <stdio.h>
int foo(char *message)
{
int error = 0;
if (message)
printf("%s\n", message);
else
error = 1; return error;
}
int call_a_function(int (*func)(char *), char *arg) {
return (*func)(arg);
}
int main(int argc, char *argv[])
{
int (*func)(char *);
char *arg;
if (argc == 2) {
func = foo;
arg = argv[1];
return call_a_function(func, arg);
} else {
return 1; }
}