After the first loop, the iteration ignores the "Name of employee #: " and jumps to "Employee's hourly rate: " and "Hours worked: " for the rest of the loop until it finishes. The problem started after I added the "Float" arrays in the "For Loop".
This is the output I am getting:
Name of Employee 1: Alex Employee's hourly rate: 9.00 Hours Worked: 8
Name of employee 2: Employee's hourly rate:9.50 Hours worked: 8
Name of employee 3: Employee's hourly rate:10.00 Hours worked: 8
etc...
#include <stdio.h>
int main()
{ int i;
char empNames[5][32];
float empRates[5][10];
float empHours[5][10];
for (i = 0; i < 5; i++)
{
printf("Name of employee %d: ", i+1);
gets(empNames[i]);
printf("Employee's hourly rate: ");
scanf_s("%f", &empRates);//squiggly green line
printf("Hours Worked: ");
scanf_s("%f", &empHours);//squiggly green line
}
}
Errors: - Warning C4477 'scanf_s' : format string '%f' requires an argument of type 'float ', but variadic argument 1 has type 'float ()[5][10]'.
-Warning C6272 Non-float passed as argument '2' when float is required in call to 'scanf_s' Actual type: 'float [5][10]'.
-Warning C4013 'gets' undefined; assuming extern returning int.