hello all,
I have a quick question about structures in C and how to properly use them.
I'm making an Inventory program and i have to show things like what inventory i have, name of part, price, qty on hand.
I here is the code I have so far declaring them and all:
now, I want to output the part section to the screen and this is giving me trouble.. I was able to show the customer information ok but the rest is not workingCode:#define NAME_LENGTH 31 #define ADDRESS_LENGTH 51 #define NUMBER_LENGTH 21 #define PART_LENGTH 6 #define PRICE_LENGTH 6 #define QUANTITY_LENGTH 6 #define TRUE 1 #define FALSE 0 /* Structure defining a name */ struct Name { char firstname[NAME_LENGTH]; }; /* Structure defining an address */ struct AddressRecord { struct Name name; char address[ADDRESS_LENGTH]; }; /* Structure defining an address */ struct PhoneRecord { struct Name name; char number[NUMBER_LENGTH]; }; /* Structure defining an part */ struct PartRecord { struct Name part; char partName[PART_LENGTH]; }; /* Structure defining an price */ struct PriceRecord { struct Name price; char price1[PRICE_LENGTH]; }; /* Structure defining quantity on hand */ struct QuantityRecord { struct Name quantity; char qty[QUANTITY_LENGTH]; };
and as you can see I have yet to put in the rest of the info for the customer like the address, and what they bought.Code:/* Outputs the name and number from a phone record */ //THIS WORKS FINE..... void show_record(struct PhoneRecord record) { printf("\n%s\t%s", record.name.firstname,record.number); } //THIS gives me the errors void show_Invrecord(struct PhoneRecord PartRecord) { printf("\n%s\t%s\t%s", PartRecord.partName,PartRecord.name.price1,PartRecord.name.qty); }
any help would be appreciated!
Thank you!
P.S. Please dont pay attention to my signature... lol as you can see it's been a looong time since been on this site.. haha


Reply With Quote
