Solved

Source Code Needed

Posted on 1997-04-06
2
213 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

Independent Software Vendors: 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

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

730 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