I was going to post this in a thread, but it turned into something a bit more serious and may be useful as a code snippet.
The code shows three files:
- menu.h: The header file for the menu library.
- menu.c: Implementation of the menu library functions.
- main.c: A sample driver that uses the library.
The menu library is fairly generic in that you can provide a format string of menu options and possible matching input values. See main.c for an example of how to use it.