diffrence between "function pointer" and "pointer to a function"

Discussion in 'C Programming' started by murgan, Dec 19, 2005.

  1. murgan

    murgan Guest

    Hi people,
    i am new to this group,this is my first query,

    friends i want to know the difference between "function pointer" and
    "pointer to a function" in c lang, so friends please send the answers
    as early as possible, thanking u all


    vijay
    murgan, Dec 19, 2005
    #1
    1. Advertising

  2. Re: diffrence between "function pointer" and "pointer to afunction"

    "murgan" <> writes:
    > friends i want to know the difference between "function pointer" and
    > "pointer to a function" in c lang, so friends please send the answers
    > as early as possible, thanking u all


    As far as I know, they're just two different ways of saying the same
    thing.

    Please use proper capitalization, and avoid abbreviations like "u" for
    "you"; they make your text more difficult to read.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
    Keith Thompson, Dec 19, 2005
    #2
    1. Advertising

  3. murgan

    Guest

    function pointer means function returning pointer.
    1)int * add(int x,int y)
    {
    int z;
    z = x+y;
    return(&z);
    }
    we may put a function call as follows
    int *a;
    a = add(x,y);

    2)pointer to a function is a function whic in turn points to another
    function.
    like
    int add();
    int (*addi)();
    addi =&add;
    then (*addi)() represents add();

    this is the difference b'wn function pointer and pointer to a function.
    , Dec 19, 2005
    #3
  4. said:

    > function pointer means function returning pointer.


    No, it doesn't.

    > 2)pointer to a function is a function whic in turn points to another
    > function.


    No, it isn't.

    > this is the difference b'wn function pointer and pointer to a function.


    No, it isn't.

    A pointer to a function is a pointer that points to a function. A function
    pointer is a pointer that either has an indeterminate value, or has a null
    pointer value, or points to a function.

    --
    Richard Heathfield
    "Usenet is a strange place" - dmr 29/7/1999
    http://www.cpax.org.uk
    email: rjh at above domain (but drop the www, obviously)
    Richard Heathfield, Dec 19, 2005
    #4
  5. murgan

    Flash Gordon Guest

    wrote:

    Please provide context. See http://cfaj.freeshell.org/google/

    > function pointer means function returning pointer.


    No, when people say function pointer they normally mean a pointer to a
    function. At least, that has been the case every time I've seen the term
    used (and I've both seen and used it a fair bit) it has meant a pointer
    to a function.

    > 1)int * add(int x,int y)


    This I ouw call a function returning a pointer to in, or if I'm not
    bothered about the type a function returning a pointer.

    > {
    > int z;
    > z = x+y;
    > return(&z);
    > }
    > we may put a function call as follows
    > int *a;
    > a = add(x,y);
    >
    > 2)pointer to a function is a function whic in turn points to another
    > function.
    > like
    > int add();
    > int (*addi)();
    > addi =&add;


    You don't need the & although it does no harm.

    > then (*addi)() represents add();
    >
    > this is the difference b'wn function pointer and pointer to a function.


    Maybe the way you use the terms, but that is not what I've come across
    in far too many years of programming in many languages.
    --
    Flash Gordon
    Living in interesting times.
    Although my email address says spam, it is real and I read it.
    Flash Gordon, Dec 19, 2005
    #5
  6. murgan

    John Bode Guest

    murgan wrote:
    > Hi people,
    > i am new to this group,this is my first query,
    >
    > friends i want to know the difference between "function pointer" and
    > "pointer to a function" in c lang, so friends please send the answers
    > as early as possible, thanking u all
    >


    They're just two different ways of describing the same thing as far as
    I know.
    John Bode, Dec 19, 2005
    #6
  7. murgan

    Thad Smith Guest

    Richard Heathfield wrote:

    > said:
    >
    >>function pointer means function returning pointer.

    >
    > No, it doesn't.
    >
    >
    >>2)pointer to a function is a function whic in turn points to another
    >>function.

    >
    > No, it isn't.


    He, he, when I read kishore's response, I swear there was a line saying
    <enable twisted homework response mode>. Maybe that didn't come though
    on your copy. ;-)

    --
    Thad
    Thad Smith, Dec 21, 2005
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mohammed rafi
    Replies:
    3
    Views:
    14,338
    Charles Bailey
    May 7, 2004
  2. mohammed rafi
    Replies:
    1
    Views:
    1,282
    ben cohen
    May 6, 2004
  3. ITpro
    Replies:
    2
    Views:
    2,595
    David N. Welton
    Oct 29, 2005
  4. Luai

    Diffrence between ++i and i++

    Luai, Apr 12, 2004, in forum: C Programming
    Replies:
    12
    Views:
    11,563
    Mabden
    May 7, 2004
  5. jigsaw
    Replies:
    4
    Views:
    443
    Gimmmo
    May 8, 2006
Loading...

Share This Page