Although I've programmed a lot in different languages but I'm new to VC++. A typical requirement is: I need to build a list for some customers. Each customer record has a list of item purchased. So I think I could define a customer record as:
typedef struct CustRcd {
char *name;
int num_purchases;
struct Purchases *purchased_item;
//points to the first item
struct CustRcd *nextCust;
} CustRcd;
typedef struct Purchases {
char purchaseItemName[LINESIZE];
struct Purchases *nextItem;
} Purchases;
Assume a customer could be appended to the list before making the first purchase. Question is: should I make purchased_item point to NULL when the customer has not purchased anything? I have tried to use this method but I experienced some problems. Eventually I end up a solution by making each newly added customer purchase one dummy item!! I think I've missed something but still struggling with no idea. Can someone enlighten me?
If the above question is hard to comprehen, can someone point me to a link (something like a tutorial/exercise with an answer) where it could show me how codes should be structured? Thanks a lot.
typedef struct CustRcd {
char *name;
int num_purchases;
struct Purchases *purchased_item;
//points to the first item
struct CustRcd *nextCust;
} CustRcd;
typedef struct Purchases {
char purchaseItemName[LINESIZE];
struct Purchases *nextItem;
} Purchases;
Assume a customer could be appended to the list before making the first purchase. Question is: should I make purchased_item point to NULL when the customer has not purchased anything? I have tried to use this method but I experienced some problems. Eventually I end up a solution by making each newly added customer purchase one dummy item!! I think I've missed something but still struggling with no idea. Can someone enlighten me?
If the above question is hard to comprehen, can someone point me to a link (something like a tutorial/exercise with an answer) where it could show me how codes should be structured? Thanks a lot.