Below is a function used to enter customer details. Under that is a function that should display the details entered as a list. num_of_items_i is a global variable. When i enter details and then select yes to enter another set of details, instead of displaying them both, it only displays the last set of details i entered. Does anyone know why this is happening?
Thankyou
Code:/* ADD CUSTOMER TO CURRENT LIST */ void f_add_customer (char *file_type) { int time_i; char reply_c; num_of_items_i =0; do { printf ("Enter Forename > "); gets ( customer[num_of_items_i ].forename_s ); printf ("Enter Surname > "); gets ( customer[num_of_items_i ].surname_s ); printf ("Enter First line of Address > "); gets ( customer[num_of_items_i ].address1_s ); fflush ( stdin ); printf ("Enter Second line of Address > "); gets ( customer[num_of_items_i ].address2_s ); printf ("Enter Post Code > "); gets ( customer[num_of_items_i ].postcode_s ); printf ("Enter Telephone number > "); gets ( customer[num_of_items_i ].telephone_s ); fflush(stdin); do { printf ("Another? Y/N > "); scanf ("%c", &reply_c ); fflush(0); if (( reply_c != 'Y' ) && ( reply_c != 'y' ) && ( reply_c != 'N' ) && ( reply_c != 'n' )) { printf ("Error. Enter Y or N only\n"); } } while (( reply_c != 'Y' ) && ( reply_c != 'y' ) && ( reply_c != 'N' ) && ( reply_c != 'n' )); } while (( reply_c != 'N' ) && ( reply_c != 'n' )); num_of_items_i ++; } /* ************************************ */ /* DISPLAY CUSTOMER NAMES */ void f_display_customer () { int num_i; num_of_items_i =0; printf("____________________________________________\n"); printf(" CUSTOMER INFORMATION \n"); printf("____________________________________________\n"); printf("No Name\t\t\t\t\tAddress\t\t\tTel.No Time\n"); for (num_i = 0; num_i < num_of_items_i; num_i ++); printf ("%d %s %s %s, %s, %s %s %d\n", num_i + 1, customer[num_i].forename_s, customer[num_i].surname_s, customer[num_i].address1_s , customer[num_i].address2_s , customer[num_i].postcode_s, customer[num_i].telephone_s, customer[num_i].time_i ); printf("___________________________________________\n\n\n\n\n"); } /* ***************************** */



LinkBack URL
About LinkBacks


