Solved

Source Code Needed

Posted on 1997-04-06
2
214 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Accepted Solution

by:
reyelts earned 50 total points
ID: 1249828
 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
ID: 1249829
I am only able to work in C right now.  This will help.  Thank you very much...
-greedyfly
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
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 recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

729 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