fscanf function won't read my float value...?
alright, well heres the problem... i have to read this data from a file...
Employee_No. Department Pay_Rate Exempt Hours_Worked Base_Pay
0101 41 8.11 Y 49
0722 32 7.22 N 40
1273 23 5.43 Y 39
2584 14 6.74 N 45
i need to create an employee register.. heres what i have so far.. the problem IS i cant figure out how to get the pay rate to read so that i can multiply it by the hours worked in order to calculate the base pay... I COULD use %s to read the pay rate, but you can't multiply an integer by a sequence... i feel like i've tried everything ALL day trying to figure out how to get the fscanf function to read my pay rate numbers... any help would be really appreciated. :)
Code:
#include <stdafx.h>
int main (void)
{
//Local Declarations
FILE *spEmployeeData;
char* titl1 [12];
char* titl2 [11];
char* titl3 [8];
char* titl4 [8];
char* titl5 [12];
char* titl6 [8];
char* num [4];
int* deprt;
float* rate;
int* hours;
int* base;
int* exempt [1];
float* pay;
//Statements
printf("\t\tEmployee files and payroll register.\n\n");
spEmployeeData = fopen("EmployeeData.txt", "r");
if (!spEmployeeData)
{
printf("\t\tCould not open input file.\n");
return (1);
}// if open file fails
fscanf(spEmployeeData, "%s%s%s%s%s%s", &titl1, &titl2, &titl3, &titl4, &titl5, &titl6);
printf("\t%s %s %s %s %s %s\n", titl1, titl2, titl3, titl4, titl5, titl6);
fscanf (spEmployeeData, "%s%d%.2f", &num, &deprt, &rate);
printf("%s %d %.2f", num, deprt, rate);//i need to continue with this pattern in order to read the rest of my data...
//i stopped here, because i can't get &rate to read properly!?
fclose(spEmployeeData);
return 0;
}//main