diff --git a/build-project.sh b/build-project.sh index f63d636..f1b79f2 100755 --- a/build-project.sh +++ b/build-project.sh @@ -1,6 +1,6 @@ clear ceedling test:all cd src/ -gcc main.c mainMenu.c -o main +gcc main.c mainMenu.c -o main ./main -rm main \ No newline at end of file +rm main diff --git a/src/CustomerData.txt b/src/CustomerData.txt index 3ac070f..b4ef5a9 100644 --- a/src/CustomerData.txt +++ b/src/CustomerData.txt @@ -4,3 +4,5 @@ forename=Max Surname=Mustermann password=example balance=0 + + diff --git a/src/LoginCustomer.h b/src/LoginCustomer.h index 809765b..e1c68e8 100644 --- a/src/LoginCustomer.h +++ b/src/LoginCustomer.h @@ -2,7 +2,7 @@ #include #include #include -#include "CustomerProperties.h" +#include "customerProperties.h" #define MAX_LOGIN_ATTEMPTS 3 char *generateCheckString(char *, char*); bool checkLogin(bool); diff --git a/src/CreateCustomer.c b/src/createCustomer.c similarity index 93% rename from src/CreateCustomer.c rename to src/createCustomer.c index a84ed15..6207847 100644 --- a/src/CreateCustomer.c +++ b/src/createCustomer.c @@ -1,13 +1,5 @@ -#include "CreateCustomer.h" +#include "createCustomer.h" /*Code written by Julius Philipp Engel, fdai7057*/ - -/* -int main() -{ - collectCustomerProperties(); -} -*/ - int generateID() { srand(clock()); @@ -27,6 +19,7 @@ void collectCustomerProperties() int letterMaximum = 15; char userInput=' '; bool inputTooLong = false; + fflush(stdin); printf("To create a new user, enter the information required below.\n"); printf("Enter forename (max. 15 letters):\n"); while(letterCounter=letterMaximum){ + if(letterCounter>=letterMaximum+5){ inputTooLong = true; break; } diff --git a/src/CreateCustomer.h b/src/createCustomer.h similarity index 84% rename from src/CreateCustomer.h rename to src/createCustomer.h index a7fdbc8..bd58756 100644 --- a/src/CreateCustomer.h +++ b/src/createCustomer.h @@ -2,7 +2,7 @@ #include #include #include -#include "CustomerProperties.h" +#include "customerProperties.h" int generateID(); void collectCustomerProperties(); void writeCustomerPropertiesToFile(customer_t *); diff --git a/src/CustomerProperties.h b/src/customerProperties.h similarity index 100% rename from src/CustomerProperties.h rename to src/customerProperties.h diff --git a/src/main.c b/src/main.c index b37734e..6849dfd 100644 --- a/src/main.c +++ b/src/main.c @@ -1,8 +1,6 @@ #include "mainMenu.h" -int main() { - - ageInput(); - - return 0; +int main() +{ + ageInput(); } diff --git a/src/mainMenu.c b/src/mainMenu.c index dd249fc..827dfde 100644 --- a/src/mainMenu.c +++ b/src/mainMenu.c @@ -1,4 +1,5 @@ #include"mainMenu.h" +#include"createCustomer.c" bool agePermission(int age) @@ -23,7 +24,7 @@ bool checkIfInteger(char* userInput) void ageInput() { - char* userInput = malloc(20*sizeof(char*)); + char* userInput = malloc(20*sizeof(char)); char* userInputPointer; long age; @@ -31,6 +32,8 @@ void ageInput() printf("\nPlease specify your age : "); scanf("%s",userInput); + int c; + while ((c = getchar()) != '\n' && c != EOF) {}; while (true) { @@ -38,10 +41,10 @@ void ageInput() if((checkIfInteger(userInput))&& (agePermission(age))) { - //age = strtol(userInput,&userInputPointer,10); - - printf("Access granted!\n\n\n\n"); + age = strtol(userInput,&userInputPointer,10); + //printf("Access granted!\n\n\n\n"); + collectCustomerProperties(); showMenu(); break; @@ -61,7 +64,9 @@ void ageInput() { printf("input invalid! try again!\n"); + fflush(stdin); scanf("%s",userInput); + fflush(stdin); } diff --git a/tests/test_CreateCustomer.c b/tests/test_CreateCustomer.c index 5ec9af0..5cf0933 100644 --- a/tests/test_CreateCustomer.c +++ b/tests/test_CreateCustomer.c @@ -1,6 +1,6 @@ #include #include -#include "CreateCustomer.h" +#include "createCustomer.h" void setUp(){} void tearDown(){}