|
|
@ -1,5 +1,4 @@ |
|
|
|
#include "CreateCustomer.h" |
|
|
|
#include "CustomerProperties.h" |
|
|
|
|
|
|
|
int generateID() |
|
|
|
{ |
|
|
@ -76,4 +75,23 @@ void collectCustomerProperties() |
|
|
|
scanf("%f",&instance.balance); |
|
|
|
|
|
|
|
printf("Account successfully created. Your ID is: %d. Note it somewhere!\n",instance.ID); |
|
|
|
customer_t *referenceToCustomerInstance = &instance; |
|
|
|
writeCustomerPropertiesToFile(referenceToCustomerInstance); |
|
|
|
} |
|
|
|
|
|
|
|
void writeCustomerPropertiesToFile(customer_t *referenceToCustomerInstance) |
|
|
|
{ |
|
|
|
FILE *customerData = fopen("CustomerData.txt","a"); |
|
|
|
if(customerData!=NULL){ |
|
|
|
/*calling generateCheckString() at this place in future*/ |
|
|
|
fprintf(customerData,"ID=%d\nForename=%s\nSurname=%s\nPassword=%s\nBalance=%.4f€\n\n", |
|
|
|
referenceToCustomerInstance->ID,referenceToCustomerInstance->forename, |
|
|
|
referenceToCustomerInstance->surname,referenceToCustomerInstance->password, |
|
|
|
referenceToCustomerInstance->balance); |
|
|
|
fclose(customerData); |
|
|
|
} |
|
|
|
else{ |
|
|
|
printf("Error when accessing the file.\n"); |
|
|
|
exit(-1); |
|
|
|
} |
|
|
|
} |