function pointer

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • skim218

    function pointer

    Why "func1=&fun c2" and "func1=func 2" has same result?
    should it be..
    func1=&func2
    *func1=func2
    ??

    Thanks

    /*************** *************** *************** ***/

    #include <stdio.h>

    int func2(int arg) {
    return arg * arg;
    }

    int (*func1)(int arg);

    int main(void) {
    func1 = &func2;
    printf("result 1: %d\n", func1(3));

    func1 = func2;
    printf("result 2: %d\n", func1(3));

    return 0;
    }
  • lawrence.jones@siemens.com

    #2
    Re: function pointer

    Bartc <bc@freeuk.comw rote:
    >
    What would have been the consequences of insisting on the &func form only?
    When? If DMR had done it way back when there wouldn't have been any but
    if the ANSI committee had tried to do it it would have broken a lot of
    existing code.

    -Larry Jones

    Temporary insanity! That's all it was! -- Calvin

    Comment

    Working...