@ -17,18 +17,18 @@ int StringLengthCounter(char* string)
}
bool isValidEmployeeID ( char * employeeId , int maximumLength )
bool isValidEmployeeID ( const char * employeeId , int maximumString Length )
{
int employeeIdLength = strlen ( employeeId ) ;
int i ;
for ( i = 0 ; i < employeeIdLength ; i + + )
for ( int i = 0 ; i < employeeIdLength ; i + + )
{
if ( employeeId [ i ] = = ' ' )
{
return false ;
}
}
return employeeIdLength < = maximumLength ;
return employeeIdLength < = maximumString Length ;
}
bool createNewEmployee ( char * employeeId , char * employeePassword )
@ -54,25 +54,27 @@ bool createNewEmployee(char* employeeId, char* employeePassword)
void getNewEmployeeCredentials ( )
{
int n ewE mployeeIdlength = 21 ;
char n ewE mployeeId[ n ewE mployeeIdlength] ;
char n ewE mployeePassword[ n ewE mployeeIdlength] ;
const int employeeIdlength = 21 ;
char employeeId [ employeeIdlength ] ;
char employeePassword [ employeeIdlength ] ;
printf ( " please enter your wished Id : \n " ) ;
scanf ( " %[^ \n ]s " , newEmployeeId ) ;
/*Added the regular expression [^\n] so that the string keep on getting read until a newline '\n' is found*/
scanf ( " %[^ \n ]s " , employeeId ) ;
newEmployeeId [ newEmployeeIdlength ] = ' \0 ' ;
employeeId [ employeeIdlength ] = ' \0 ' ;
printf ( " \n please enter your wished Password : \n " ) ;
scanf ( " %s " , n ewE mployeePassword) ;
scanf ( " %s " , employeePassword ) ;
n ewE mployeePassword[ n ewE mployeeIdlength] = ' \0 ' ;
employeePassword [ employeeIdlength ] = ' \0 ' ;
if ( isValidEmployeeID ( n ewE mployeeId, n ewE mployeeIdlength) )
if ( isValidEmployeeID ( employeeId , employeeIdlength ) )
{
createNewEmployee ( n ewE mployeeId, n ewE mployeePassword) ? 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 " ) ;
createNewEmployee ( employeeId , employeePassword ) ? 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