Hi guys, I've run into a bit of a problem when it comes to outputting my info into a txt file.
I want to print a title so that people know what they're are looking at when they open this file my program creates. However, I have several rows/columns of info to be printed to file, and it seems to want to print the title with each row.
This is what my program is doing now:
CODE
Welcome to the payroll journal.0101 41 8.11 49 Y 397.39
Welcome to the payroll journal.0722 32 7.22 40 N 288.80
Welcome to the payroll journal.1273 23 5.43 39 Y 211.77
Welcome to the payroll journal.2584 14 6.74 45 N 303.30
Welcome to the payroll journal.4885 21 8.00 38 Y 304.00
! Note this is the output file
This is what I want my program to print out:
CODE
Welcome to the payroll journal.
0101 41 8.11 49 Y 397.39
0722 32 7.22 40 N 288.80
1273 23 5.43 39 Y 211.77
2584 14 6.74 45 N 303.30
4885 21 8.00 38 Y 304.00
I'd also like to print labels to each of the columns, but that's not as important.
I have the code that I'm using for this here:
CODE
/*=========================Write Payroll Journal=======================
Finally, we will create a file for the payroll journal
*/
int createpay (FILE* payjournal, int empnum, int dept,
float payrt, char exmpt, int hours, float paygross)
{
//Statements
fprintf(payjournal, "Welcome to the payroll journal.");
fprintf(payjournal, "%04d %2d %.2f %2d %c %.2f\n\n",
empnum, dept, payrt, hours, exmpt, paygross);
printf("%04d\t\t %2d\t$%.2f\t %2d\t %c\t $%.2f\n\n", empnum, dept, payrt, hours, exmpt, paygross);
return 0;
}
If someone can please point out what I'm doing wrong and show me the solution specifically in C (not C++), I'd appreciate it.