I compile my program and it compiles fine...but when I run it..I come up with zero's for all integers and blanks for strings...
can anyone see anything wrong? I at my wits ends and now wondering if the data is even being read properly...
Code:#include <iostream> using namespace std; #include <iomanip.> #include <stdio.h> #include <string.h> #include <cstring> struct employee { int id; char name[10]; float pr; int csalary; int raise; double rate; int nsalary; }; void alpha(struct employee *records); void calc(struct employee *records); void display(struct employee *records); main() { char tmp[100]; struct employee records[14]; int i=0; FILE *fPtr; fPtr = fopen("lab2.txt", "r"); do { fgets(tmp,200,fPtr); sscanf(tmp, "%d %s %f %d", &records[i].id, &records[i].name, &records[i].pr, &records[i].csalary); } while (!(feof(fPtr))); printf("ID Name PR Current Salary $ pct New Salary "); printf("\n================================================================\n"); //readfile(records, buf); alpha(records); calc(records); display(records); } void alpha(struct employee *records) { { for(int n=1; n<= 13; n++) for (int i=1; i<= 12; i++ ) { int j=i++; int result = strcmp ( records[i].name, records[j].name); if ( result > 0 ) swap( i,j ); } } } void calc(struct employee *records) { for (int i=0; i<=12; i++){ if (records[i].pr ==1) records[i].rate = 1.045; if (records[i].pr ==2) records[i].rate = 1.06; if (records[i].pr ==3) records[i].rate = 1.078; if (records[i].pr ==4) records[i].rate = 1.09; records[i].nsalary = (records[i].csalary*records[i].rate); records[i].raise = (records[i].nsalary-records[i].csalary); records[i].rate = ((records[i].rate*100)-100); } } void display(struct employee *records) { for (int i=0; i<=12; i++) printf("%d %s %.0f %d %d %.2f %d\n", records[i].id, records[i].name, records[i].pr, records[i].csalary, records[i].raise, records[i].rate, records[i].nsalary); }