Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <stdio.h>
- #include <stdlib.h>
- #include <ctype.h>
- #include <string.h>
- #define PAUSE system("pause")
- #define CLS system("cls")
- #define FLUSH fflush(stdin)
- typedef struct
- {
- char name[40];
- int customerID;
- double amountOwning;
- }CUSTOMER;
- CUSTOMER* makeACustomer()
- {
- CUSTOMER* result;
- result = malloc(sizeof(CUSTOMER));
- return result;
- }// end of didn't even prototype the factoryFunction();
- void getCustomerInfo(CUSTOMER* customer){
- printf("Enter the Customer's name:");
- scanf("%s", customer->name);
- printf("Enter the Customer's ID:");
- scanf("%i", customer->customerID);
- printf("Enter the Amount owed:");
- scanf("%lf", customer->amountOwning);
- }// end of getcustomerinfo()
- main()
- {
- int i;
- CUSTOMER myCustomers[10];
- CUSTOMER *myDynamicCustomers;
- CUSTOMER* *myIndividualCustomers;
- CUSTOMER firsCustomer;
- getCustomerInfo(&firsCustomer);
- myIndividualCustomers = calloc(10, sizeof(CUSTOMER*));
- for (i = 0; i < 10; i++)
- {
- myIndividualCustomers[i] = makeACustomer();
- }// end of for loop.
- myDynamicCustomers = calloc(10, sizeof(CUSTOMER));
- if (myCustomers == NULL)
- {
- printf("Error allocating memory...");
- exit(-1);
- }// end of if statement
- strcpy(myIndividualCustomers[0]->name, "Judy XXXXX");
- myIndividualCustomers[0]->amountOwning = 789.99;
- myIndividualCustomers[0]->customerID = 789456;
- strcpy(myCustomers[0].name, "Bob Smith");
- myCustomers[0].customerID = 12345;
- myCustomers[0].amountOwning = 123.45 ;
- strcpy(myCustomers[1].name, "Mary Jones");
- myCustomers[1].customerID = 54321;
- myCustomers[1].amountOwning = 456.78;
- strcpy(myCustomers[2].name, "Judy XXXXXX");
- myCustomers[2].customerID = 1017;
- myCustomers[2].amountOwning = 6767.21;
- free(myDynamicCustomers);
- PAUSE;
- }// end of main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement