Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 851279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:24:15+00:00 2026-05-15T07:24:15+00:00

Possible Duplicate: How does dereferencing of a function pointer happen? Hi All, Why these

  • 0

Possible Duplicate:
How does dereferencing of a function pointer happen?

Hi All,
Why these two codes give the same output,
Case 1:

#include <stdio.h>

typedef void (*mycall) (int a ,int b);
void addme(int a,int b);
void mulme(int a,int b);
void subme(int a,int b);

main()
{
    mycall x[10];
    x[0] = &addme;
    x[1] = &subme;
    x[2] = &mulme;
    (x[0])(5,2);
    (x[1])(5,2);
    (x[2])(5,2);
}

void addme(int a, int b) {
    printf("the value is %d\n",(a+b));
}
void mulme(int a, int b) {
    printf("the value is %d\n",(a*b));
}
void subme(int a, int b) {
    printf("the value is %d\n",(a-b));
}

Output:

the value is 7
the value is 3
the value is 10

Case 2 :

#include <stdio.h>

typedef void (*mycall) (int a ,int b);
void addme(int a,int b);
void mulme(int a,int b);
void subme(int a,int b);

main()
{
    mycall x[10];
    x[0] = &addme;
    x[1] = &subme;
    x[2] = &mulme;
    (*x[0])(5,2);
    (*x[1])(5,2);
    (*x[2])(5,2);
}

void addme(int a, int b) {
    printf("the value is %d\n",(a+b));
}
void mulme(int a, int b) {
    printf("the value is %d\n",(a*b));
}
void subme(int a, int b) {
    printf("the value is %d\n",(a-b));
}

Output:

the value is 7
the value is 3
the value is 10
  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T07:24:16+00:00Added an answer on May 15, 2026 at 7:24 am

    I’ll simplify your question to show what I think you want to know.

    Given

    typedef void (*mycall)(int a, int b);
    mycall f = somefunc;
    

    you want to know why

    (*f)(5, 2);
    

    and

    f(5.2);
    

    do the same thing. The answer is that a function name both represent a “function designator”. From the standard:

    "A function designator is an expression that has function type. Except when it is the
    operand of the sizeof operator or the unary & operator, a function designator with
    type ‘‘function returning type’’ is converted to an expression that has type ‘‘pointer to
    function returning type’’."
    

    When you use the indirection operator * on a function pointer, that dereference is also a “function designator”. From the standard:

    "The unary * operator denotes indirection. If the operand points to a function, the result is
    a function designator;..."
    

    So f(5,2) becomes essentially (*f)(5,2) by the first rule. This becomes call to function designated by f with parms (5,2) by the second. The result is that f(5,2) and (*f)(5,2) do the same thing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How does dereferencing of a function pointer happen? If we have void
Possible Duplicate: How does dereferencing of a function pointer happen? void myprint(char* x) {
Possible Duplicate: why does initializing subclasses require calling the super class's same init function?
Possible Duplicate: Does the compiler continue evaluating an expression where all must be true
Possible Duplicate: When does invoking a member function on a null instance result in
Possible Duplicate: Does readdir() guarantee an order? I'm guessing this isn't the case, and
Possible Duplicate: Does anyone have a good Proper Case algorithm I am currently in
Possible Duplicate: How does this “size of array” template function work? Is there any
Possible Duplicate: does these code has memory leakage?? static private ArrayList seriesColors = new
Possible Duplicate: What does this “(function(){});”, a function inside brackets, mean in javascript ?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.