[prog] ncurses menu code
ed orphan
millward at Ms.UManitoba.CA
Fri Jul 30 10:00:30 EST 2004
There's a line of code in the Ncurses Programming HOWTO
I need help understanding. It's the last example in
the chapter on menus, example 24, Menu User Pointer Usage.
In the switch,
case 10: /* Enter */
{ ITEM * cur; pointer to a menu item declared
void (*p) (char * ); pointer declared to a function that
returns void and has a char pointer as an argument.
cur = current_item( my_menu );
current_item returns a pointer to the current item in
the menu called my_menu.
p = item_userptr( cur );
Assigning the function item_userptr( cur ) to the
function pointer p. ( why I have no idea ).
All the man file says about item_userptr is that:
"Every menu item has a field that can be used to
hold application-specific data". item_userptr
retrieves that field.
p( ( char *)item_name( cur ) );
Dah? What is this?
I know that item_name returns the name part of the
the given item and is defined as:
const char *item_name(const ITEM *item)
What does this statement do?
Is there a simpler, more understandable method to
get the same job done?
Any information would be very welcome. Thanks.
More information about the Programming
mailing list