Declare “a function with argument of int* which returns pointer to an array of 4 integer pointers”.
At the first glance it may look complex, we can declare the required function with a series of decomposed statements.
1. We need, a function with argument int *,
2. a function with argument int *, returning pointer to
3. a function with argument int *, returning pointer to array of 4
4. a function with argument int *, returning pointer to array of 4 integer pointers
int *(*function(int *));
How can we ensure that the above declaration is correct? The following program can cross checks our declaration,
The macro SIZE_OF_ARRAY is used for symbolic representation of array size. p_array_t is typedefined as “pointer to an array of 4 integers”. If our declaration is wrong, the program throws an error at the ‘function‘ definition.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- How to declare a pointer to a function?
- Pointers in C and C++ | Set 1 (Introduction, Arithmetic and Array)
- Why C treats array parameters as pointers?
- Different ways to declare variable as constant in C and C++
- Pointer to an Array | Array Pointer
- Sum of array using pointer arithmetic
- std::tuple, std::pair | Returning multiple values from a function using Tuple and Pair in C++
- Passing and Returning Objects in C++
- Input an integer array without spaces in C
- What is a Pointer to a Null pointer
- Features and Use of Pointers in C/C++
- Pointers and References in C++
- Pointers in C/C++ with Examples
- Applications of Pointers in C/C++
- Pointers vs References in C++