Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Are these lines of code in C programming the same

Are these 2 lines of code the same ??

line 1:

void (**foo)(int)

line 2

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

void *(*foo)(int)

Kindly help me understand on what is happening.

>Solution :

They are not the same.

void (**foo)(int);

foo is a pointer to a pointer to a function that takes an int parameter and returns void.

void *(*foo)(int):

foo is a pointer to a function that takes an int parameter and returns a pointer to void.

Postfix operators like () and [] have higher precedence than unary *, so

T *a[N];    // a is an array of pointer to T
T (*a)[N];  // a is a pointer to an array of T

T *f();     // f is a function returning pointer to T
T (*f)();   // f is a pointer to a function returning T
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading