Solved

Source Code Needed

Posted on 1997-04-06
2
204 Views
Last Modified: 2010-04-15
I am writing a Home Inventory Program and am in over my head.  I am looking for source code, not to copy but to get ideas from.....
0
Comment
Question by:greedyfly
2 Comments
 

Accepted Solution

by:
reyelts earned 50 total points
Comment Utility
 For what platform? In any event, it would probably be best to
write this sort of program in C++ ( it seems to lend itself to
that ). If however you don't know C++ you can simulate
object-orientedness using C, just with typedefs.

  If an item/object is the base of the model than you can do something like this...

  /* The condition of an item */
  typedef _ItemCondition enum {
    NEW,
    USED,
    WORTHLESS,
    BORROWED,
    LOANED_OUT
  } ItemCondition;
 
  /* The return status from a function call */
  typedef _ReturnStatus _enum {
    SUCCESS,
    GENERAL_FAILURE,
    BAD_ARGUMENT,
    INSUFFICIENT_MEMORY,
    INSUFFICIENT_DISK
  } ReturnStatus;
   
  /* An item */    
  typedef struct _ITEM {
    char            *sName;   /* The name of the item       */
    char            *sBrand;  /* The brand of the item      */
    ItemCondition   Condition;
    etc...
   
    struct _ITEM*   NextItem;
    struct _ITEM*   PreviousItem;

  } ITEM, *PITEM;

  Then you need something like the following functions.
  /* Create a new item */
  ReturnStatus NewItem( PITEM pNewItemStats );

  /* Remove an existing item */
  ReturnStatus RemoveItem( int iItemIndex );

  /* Change an item's settings */
  ReturnStatus SetItem( PITEM pItemStats, int iItemMask );

  /* Save all the items to disk */
  ReturnStatus SaveItems( PITEM pItemList );
 
  /* Load all of the items from disk */
  PITEM LoadItems();

  /* Free all of the items and resources allocated */
  ReturnStatus FreeItems( PITEM pItemList );
 
  So finally, your program looks something like...

  int main( int argc, char** argv ) {

    PITEM pItemList;  /* Pointer to the list of items */

    HandleArgs( argc, argv ); /* Deal with passed arguments */

    pItemList = LoadItems(); /* Load all of the items into mem */

    DoWhateverElseYouNeedTo();

    FreeItems( pItemList );

    return( EXIT_SUCCESS );
}
   
0
 

Author Comment

by:greedyfly
Comment Utility
I am only able to work in C right now.  This will help.  Thank you very much...
-greedyfly
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now