Q99.Marks: +2.0UGC NET Paper 2: Computer Science17th June 2023
What is x in the following program?
#include < stdio.h >
int main ( )
{typedef (* (*arrfptr [3]) ( ) ) [10];
arrfptr x;
return 0 ;
}
1.x is a pointer
2.x is a array of three pointer
3.x is an array of three function pointer✓ Correct
4.Error in x declaration
Solution
The correct answer is x is an array of three function pointer
Key PointsThe given program declares an array of three function pointers named x. Each function pointer is of type (* (*arrfptr [3]) ( ) ) [10].
typedef (* (*arrfptr[3])()) [10];
This declares arrfptr as an array of three pointers to functions with no parameters (specified by ()), and each function returns a pointer to an array of 10 elements. So, the correct answer is: x is an array of three function pointers
Additional InformationAn array of pointers in C is essentially an array where each element is a pointer. This allows you to create an ordered collection of pointers, and each pointer can point to a different location in memory. The declaration of an array of pointers involves specifying the type of the elements that the pointers will point to.