C Programming - Complicated Declarations - Discussion


Declare the following statement?
"A pointer to a function which receives an int pointer and returns float pointer".

float *(ptr)*int;
float *(*ptr)(int)
float *(*ptr)(int*)
float (*ptr)(int)

Answer: Option C


No answer description available for this question.

Mohini said: (Jan 18, 2011)  
Simple trick: 'Pointer' word is used 3 times. So somehow manage to get * three times in your answer.

Rams said: (Jul 8, 2011)  

Pardhu said: (Aug 30, 2011)  
Nice trick you told.

Pradeep Rai said: (Nov 22, 2011)  
Simple answer i.e. function declered as pointer function which recieve intger type pointer as argument and returns float type pointer.

Chandan Singh said: (Jan 14, 2013)  
(int*)= specifies that it receives an input pointer.
(*ptr)(int*)= it specifies that it is a pointer to function which receives integer pointer.
float *(*ptr)(int*)= this specifies that it returns float pointer.

Ranjith said: (Jun 1, 2013)  
Simple answer i.e. function declared as pointer function which receives integer type pointer as argument and returns float type pointer.

Navin said: (Jul 7, 2014)  
@Mohini : What will you do if there is one more option with 3 *s ?

Vasanth said: (Sep 15, 2015)  
float *(*ptr)(int*); is implicitly converted into ptr*(int*)float* which means that ptr is pointer to a function, which receives int pointer and returns float pointer.

Kartik said: (Nov 11, 2016)  
Nice trick @Mohini.

Mdv Ajay said: (Jun 15, 2017)  
Good, Thanks @Pradeep.

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.