C language with an array of strings display menu solution
- 2020-04-02 00:53:25
- OfStack
I used to write menu aspects over and over again, but I found this to be a good way to solve the traversal problem with a pointer to a pointer.
The code is as follows:
The code is as follows:
#include <stdio.h>
static char *menu[] = {
"1 --- push one item./n",
"2 --- pop one item./n",
"3 --- quit./n",
NULL
};
void Show_menu();
int main()
{
Show_menu();
return 0;
}
void Show_menu()
{
char **p;
p = menu;
while(NULL != *p)
{
printf("%s", *p);
*p ++;
}
}