All of lore.kernel.org
 help / color / mirror / Atom feed
* function Name
@ 2005-07-08  6:12 raja
  2005-07-08  7:35 ` Arjan van de Ven
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: raja @ 2005-07-08  6:12 UTC (permalink / raw)
  To: linux-kernel

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: function Name
  2005-07-08  6:12 function Name raja
@ 2005-07-08  7:35 ` Arjan van de Ven
  2005-07-08 10:00 ` Maciej Soltysiak
  2005-07-08 14:48 ` jscottkasten
  2 siblings, 0 replies; 4+ messages in thread
From: Arjan van de Ven @ 2005-07-08  7:35 UTC (permalink / raw)
  To: raja; +Cc: linux-kernel

On Fri, 2005-07-08 at 11:42 +0530, raja wrote:
> 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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: function Name
  2005-07-08  6:12 function Name raja
  2005-07-08  7:35 ` Arjan van de Ven
@ 2005-07-08 10:00 ` Maciej Soltysiak
  2005-07-08 14:48 ` jscottkasten
  2 siblings, 0 replies; 4+ messages in thread
From: Maciej Soltysiak @ 2005-07-08 10:00 UTC (permalink / raw)
  To: linux-kernel; +Cc: raja

Hello raja,

Friday, July 8, 2005, 8:12:21 AM, you wrote:
>    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



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: function Name
  2005-07-08  6:12 function Name raja
  2005-07-08  7:35 ` Arjan van de Ven
  2005-07-08 10:00 ` Maciej Soltysiak
@ 2005-07-08 14:48 ` jscottkasten
  2 siblings, 0 replies; 4+ messages in thread
From: jscottkasten @ 2005-07-08 14:48 UTC (permalink / raw)
  To: raja; +Cc: linux-kernel



--- 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;
  }
}



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-07-08 14:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-08  6:12 function Name raja
2005-07-08  7:35 ` Arjan van de Ven
2005-07-08 10:00 ` Maciej Soltysiak
2005-07-08 14:48 ` jscottkasten

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.