Hello all
I need some help with my program. Here is the jist of it. I need to write a program that pulls data from another (i.e. employee id, name, performance rating, and current salary)
then take that data and perform some calculations and the redisplay it in alphabitical order.
here is the data file...(lab2.txt)
339 GOERGE 4 26000
221 SANDY 4 22600
101 RONNY 3 35250
115 MILLY 1 40000
445 PETE 2 20335
553 BRIAN 3 34650
209 RUSS 1 40000
199 ANGIE 4 49000
241 BARRY 3 50000
322 MIKE 2 13400
789 PETER 3 35500
900 RICK 2 46000
111 WENDY 2 21000
and here is my program....My problem (at the moment is that my output is one line of o's)...
Code:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
struct employee {
int id;
char name[10];
int pr;
int csalary;
int raise;
float rate;
int nsalary;
};
main()
{
int id;
char name[10];
int pr;
int csalary;
int raise;
float rate;
int nsalary;
FILE *fPtr;
struct employee emp;
fPtr = fopen("lab2.txt", "r");
printf("ID Name PR Current Salary $ pct New Salary ");
printf("\n================================================================\n");
if(fPtr != NULL){
fread(&emp, sizeof(int),1,fPtr);
fscanf(fPtr, "%s", name);
fclose(fPtr);
//while (!(feof(fPtr)))
//{
//fscanf(fPtr,"%d%s%d%d",&id,name,&pr,&csalary);
//emp.raise= (emp.csalary * emp.rate);
//emp.nsalary= (emp.csalary + emp.raise);
}
printf("%d %s %d %d %d %.2f %d\n\n", emp.id,emp.name,emp.pr,emp.csalary,emp.raise,emp.rate,emp.nsalary);
//fclose (fPtr);
return 0;
}
thanks