Thread: Pointer to a function pointer

  1. #16
    Registered User
    Join Date
    Jan 2008
    Posts
    290
    Yaay! Ok ok, now show an example of this one!

    typedef int (*(*f)(int (*)(int)))(int (*)(int));

  2. #17
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Quote Originally Posted by arpsmack View Post
    Yaay! Ok ok, now show an example of this one!

    typedef int (*(*f)(int (*)(int)))(int (*)(int));
    Why not to do your homework by yourself?
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #18
    Registered User
    Join Date
    Jan 2008
    Posts
    290
    Umm.. that was a joke.... I was trying to come up with a ludicrous example that was hard to understand.

    Never mind. It's not funny if you have to explain it. Or maybe it's just not funny period.

  4. #19
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by arpsmack View Post
    Yaay! Ok ok, now show an example of this one!

    typedef int (*(*f)(int (*)(int)))(int (*)(int));
    f is a pointer to a function taking a pointer to a function taking int, returning int, which returns a pointer to a function taking a pointer to a function taking int returning int, which returns int.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  5. #20
    Registered User
    Join Date
    Jan 2008
    Posts
    290
    Now say it five times fast. And write an example program that uses it. And then stand on your head for 3 days while reciting the Cadaeic Cadenza.

  6. #21
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Point being, define simple types and reuse them.

    typedef void (fptr)(int);
    typedef void (fptr2)(fptr*);
    etc

    Some some better names, it all becomes so readable.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sorting number
    By Leslie in forum C Programming
    Replies: 8
    Last Post: 05-20-2009, 04:23 AM
  2. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 01:03 PM
  3. Function Pointer help
    By Skydt in forum C Programming
    Replies: 5
    Last Post: 12-02-2005, 09:13 AM
  4. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 09:32 AM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM