?
Solved

Source Code Needed

Posted on 1997-04-06
2
Medium Priority
?
216 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 100 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
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 opening and reading files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
Suggested Courses
Course of the Month15 days, 6 hours left to enroll

741 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