Skip to content

Instantly share code, notes, and snippets.

Created June 30, 2013 10:00
Show Gist options
  • Save anonymous/5894590 to your computer and use it in GitHub Desktop.
Save anonymous/5894590 to your computer and use it in GitHub Desktop.
#define _CRT_SECURE_NO_DEPRECATE
#include <stdio.h>
typedef struct _abonat
{
int id;
int number;
char *name;
float plan;
int minutes;
int used;
} Abonat;
const int MENU_LENGTH = 6;
enum menu
{
MENU_EXIT = 0,
MENU_LIST = 1,
MENU_ADD = 2,
MENU_FEES = 3,
MENU_AVG = 4,
MENU_HIGH = 5
};
char * menuItems[] = {
"0 - Exit\n",
"1 - List users\n",
"2 - Add user\n",
"3 - Calculate fees\n",
"4 - Total and average call length\n",
"5 - Highest bill\n"
};
int getMenuOption();
void displayMenu();
int main(void)
{
int opt;
while ((opt = getMenuOption()))
{
switch (opt)
{
case MENU_LIST:
break;
case MENU_ADD:
break;
case MENU_AVG:
break;
case MENU_FEES:
break;
case MENU_HIGH:
break;
default:
printf("Command - %d\n", opt);
break;
}
}
puts("Exiting\n");
return 0;
}
void displayMenu()
{
int i;
for (i = 0; i < MENU_LENGTH; i++)
{
puts(menuItems[i]);
}
}
int getMenuOption()
{
int opt;
displayMenu();
scanf("%d", &opt);
if (opt > 5 || opt < 0)
{
opt = 0;
}
return opt;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment