From: <jscottkasten@yahoo.com>
To: raja <vnagaraju@effigent.net>
Cc: linux-kernel@vger.kernel.org
Subject: Re: function Name
Date: Fri, 8 Jul 2005 07:48:22 -0700 (PDT) [thread overview]
Message-ID: <20050708144823.70503.qmail@web34413.mail.mud.yahoo.com> (raw)
In-Reply-To: <42CE1945.7080909@effigent.net>
--- raja <vnagaraju@effigent.net> wrote:
> 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.
>
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;
}
}
prev parent reply other threads:[~2005-07-08 14:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-07-08 6:12 raja
2005-07-08 7:35 ` Arjan van de Ven
2005-07-08 10:00 ` Maciej Soltysiak
2005-07-08 14:48 ` jscottkasten [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20050708144823.70503.qmail@web34413.mail.mud.yahoo.com \
--to=jscottkasten@yahoo.com \
--cc=linux-kernel@vger.kernel.org \
--cc=vnagaraju@effigent.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®