Exforsys
+ Reply to Thread
Results 1 to 2 of 2

Pointers to Functions

This is a discussion on Pointers to Functions within the C and C++ forums, part of the Programming Talk category; I am working with pointers and functions concept in C programming. Suppose there is an integer pointer exforsys it can ...

  1. #1
    Ralph is offline Senior Member Array
    Join Date
    Apr 2006
    Answers
    114

    Exclamation Pointers to Functions

    I am working with pointers and functions concept in C programming.
    Suppose there is an integer pointer exforsys it can be declared in C programming language as
    int *exforsys;
    or
    int* exforsys;

    That is the * symbol can be placed either near the variable name or near the data type. Both are allowed and refer the same meaning.

    But when I declare pointers to functions using the same concept as below
    int* (exforsys) (char* test);

    The above gives me error. I want to know the reasons for the error?


  2. #2
    caradoc is offline Senior Member Array
    Join Date
    Apr 2006
    Answers
    122
    In your declaration you have not missed the brackets but placed it wrongly. Only for simple data type pointer declarations * symbol can be placed either near the variable name or near the data type. It is not allowed for pointers to functions declaration.

    It is a must place for placing the brackets around *exforsys as
    int (*exforsys) (char* test);

    If not the declaration would be taken as function by the compiler. So one has to be very careful while declaring the Pointers to Functions and must follow the syntax usage.


Latest Article

Network Security Risk Assessment and Measurement

Read More...