Hey everyone,
I am having trouble actually using my typedef struct. The point of the program is basic inventory reporting. I have my program set up to make heavy use of functions (as a side note - is this good programming practice?). Anyway, I have the typedef declared along with all the prototype functions and global variables. I can create the program to either have the user give all the information for each individual item, or I can define the items on my own and just print a list of the items so the user knows what he has.
So here is my question: how do I declare my initial inventory items? I have Googled this and checked the forums here for awhile now, but I cannot find what I need (perhaps I'm just blind...or

). Any help, tutorials, code examples, or nudges in the right direction are greatly appreciated!
The code below is my (obviously) unfinished work thus far.
CODE
#include <stdio.h>
#include <stdlib.h>
/* prototype functions */
void header(void);
void bye(void);
void menu(void);
void itemsold(void);
void dailyreport(void);
void weeklycheck(void);
void monthlyupdate(void);
typedef struct INVEN
{
char name[13]; /* name of item */
int ID; /* ID number of item */
int curr_month; /* current month */
int actual_stock; /* number of items in-stock */
int wanted_stock; /* number of items wanted to be in-stock */
double cost; /* cost of the item */
double price; /* price of the item */
char supplier[7]; /* name of the supplier */
int month_volume; /* monthly volume */
int total_month_sales; /* total sales for current month */
} inven;
/* global variables */
int choice = 5; /* for the menu */
char a[50]; /* to catch non-integer input during the menu */
int main(void)
{
header();
menu();
bye();
return 0;
}
void header(void)
{
printf("This program is a creation of ShotoBomb.\n");
printf(" a.k.a. Kevin VanUs\n\n\n");
}
void menu(void)
{
printf ("0: Exit\n");
printf ("1: Item Sold\n");
printf ("2: Daily Report\n");
printf ("3: Weekly Check\n");
printf ("4: Monthly Update\n\n");
printf ("Please enter the number of the menu item you desire: ");
scanf ("%d", &choice);
gets(a);
if (choice == 5) /* If any non-integer is input, */
{ /* then 'choice' is set to make */
choice; /* the SWITCH go to 'default'. */
} /* ---------------------------- */
switch (choice)
{
case 0: puts("\nThank you for using Inventory Manager by ShotoBomb.\n\n\n");
break;
case 1: puts("\nitemsold()\n");
itemsold();
break;
case 2: puts("\ndailyreport()\n");
dailyreport();
break;
case 3: puts("\nweeklycheck()\n");
weeklycheck();
break;
case 4: puts("\nmonthlyupdate()\n");
monthlyupdate();
break;
default: puts("\nPlease enter a menu choice 0 - 4.\n\n");
menu();
break;
}
}
void itemsold(void)
{
//blah blah blah
menu();
}
void dailyreport(void)
{
//blah blah blah
menu();
}
void weeklycheck(void)
{
//blah blah blah
menu();
}
void monthlyupdate(void)
{
//blah blah blah
menu();
}
void bye(void)
{
puts("Normal Termination!\n");
printf("Press 'ENTER' to quit.\n");
fflush(stdout);
(void)getchar();
}
edit: minor grammatical corrections
This post has been edited by ShotokanDeity: 20 Nov, 2007 - 07:57 PM