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

explain this instruction: void(*pf)(int * const pi);

P: 1
void(*pf)(int * const pi);
i meet this instruction and i dot understand it
Nov 16 '15 #1
Share this Question
Share on Google+
1 Reply


weaknessforcats
Expert Mod 5K+
P: 9,197
The parsing always starts with the name and mover to the right until it finds a right parenthesis ) or a semi-colon ;

When either of these is encountered, the parser resumes at the place where it moved right but now it moves left. If a left parenthesis ( or the beginning of the line is encountered, the parser resumes where it left off on the right and moves right.

When the parser reaches the ; the parse is done.

OK. So here we go:

Expand|Select|Wrap|Line Numbers
  1. void(*pf)(int * const pi);
1) Start at the name an move right:
"pf" and we hit a )

2) Position where we started right and move left:
"pf is a pointer" and we hit a (

3) Position where we left off on the right:
"pf is a pointer to a function that takes a const pointer to int" and we hit a )

4) Position where we left off on the left and move left:
"pf is a pointer to a function that takes a const pointer to int and returns void" and we hit a (

5) Position where we left off on the right ad move to the right:
"pf is a pointer to a function that takes a const pointer to int and returns void" and we hit a ;

The parse is done:

"pf is a pointer to a function that takes a const pointer to int and returns void"
Nov 16 '15 #2

Post your reply

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