I have a problem with flushing the buffer, I don't wanna use fflush( stdin ) for many said that it's providing abnormal behavior. I have the program below, if I exceeded the size of the buffer I am not able to enter any input for the salary. thanks.
edit: is there any way that we could do to flush the remaining buffer without using the fflush( stdin )?Code:struct Employee enterEmpInfo()
{
struct Employee enterEmp;
int length = 0;
printf( "Employee name: " );
fgets( enterEmp.empName, 48, stdin );
length = strlen( enterEmp.empName );
enterEmp.empName[ length - 1] = '\0';
printf( "SSS Number : " );
fgets( enterEmp.empSSS, 14, stdin );
length = strlen( enterEmp.empSSS );
enterEmp.empSSS[ length - 1 ] = '\0';
printf( "Salary : " );
scanf( "%f", &enterEmp.empSalary );
return enterEmp;
}