
- Forum
- Programming Talk
- C and C++
- Pointers to Functions
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 ...
-
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?
-
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.

Reply With Quote





