By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,972 Members | 1,134 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,972 IT Pros & Developers. It's quick & easy.

What do "int *p(char *a)" & "char (*p)(int *a)" mean?

P: n/a
I cant recognise them as declarations of some arrays or so... Are they some declaration of functions with parameter & return type? If so, then how come function names are missing?
Nov 7 '10 #1
Share this Question
Share on Google+
1 Reply


weaknessforcats
Expert Mod 5K+
P: 9,197
"int *p(char *a)" & "char (*p)(int *a)" mean?

This code is written to trip you up since beginners think "p" means "pointer". Because of that assumption, you can't read this code.

Expand|Select|Wrap|Line Numbers
  1. int *p(char *a) 
is a function named "p" that takes a char* argument "a" and returns a pointer to an int. You would have no problem were it written like this:

Expand|Select|Wrap|Line Numbers
  1. int *MyFunction(char *arg)
This one:

Expand|Select|Wrap|Line Numbers
  1. char (*p)(int *a)
defines "p" to be a pointer to a function that takes an int* arguments "a" and returns a char.

I expect I am doing your homework, but at least now you know.
Nov 7 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.