diff --git a/src/createEmployeeAccount.c b/src/createEmployeeAccount.c index 7abfb02..8532456 100644 --- a/src/createEmployeeAccount.c +++ b/src/createEmployeeAccount.c @@ -53,15 +53,32 @@ bool createNewEmployee(char* employeeId, char* employeePassword) void getNewEmployeeCredentials() { - char newEmployeeId[20]; - char newEmployeePassword[20]; + + int newEmployeeIdlength = 21; + char newEmployeeId[newEmployeeIdlength]; + char newEmployeePassword[newEmployeeIdlength]; + + printf("please enter your wished Id :\n"); + + scanf(" %[^\n]s",newEmployeeId); + + newEmployeeId[newEmployeeIdlength] = '\0'; + + printf("\nplease enter your wished Password :\n"); - printf("please enter your wished Id :"); - scanf("%s",newEmployeeId); - printf("please enter your wished Password :"); scanf("%s",newEmployeePassword); - createNewEmployee(newEmployeeId,newEmployeePassword) ? printf("\n\n Account created successfully !\n\n") : printf("\n\n Could not create the Account please contact an employee of clearance 1 !\n\n"); + newEmployeePassword[newEmployeeIdlength] = '\0'; + + if(isValidEmployeeID(newEmployeeId,newEmployeeIdlength)) + { + createNewEmployee(newEmployeeId,newEmployeePassword) ? printf("\n\n Account created successfully !\n\n") : printf("\n\n Could not create the Account please contact an employee of clearance 1 !\n\n"); + } + + else + { + printf("Error : the entered ID either contains space or exceeds the maximum of 20 characters!"); + } }