Write a C program to read the list from the file
and store them in the arrays. Your program
should write the list of client’s account
number, client’s name and the client’s balance
to another file called “newdata.txt” in reversed
order and also display them on the screen.


An example of output dialog is shown below
Account Name Balance
800 Stacy 100.10
700 Michael 81.05
600 Dale 1005.30
500 Richard 214.89
400 Stone -45.23
300 White 0.00
200 John 345.67
100 Jones 24.50

--------

This is what I have done so far bellow here....But the only missing part is the reversed order of “newdata.txt”
contents. Please help! Been trying now for few days with no succes. =(

Regards,
Mark

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main()
{
FILE *ifpt,*ofpt;
int i;
double account;
double balance;
char name[25],s[60];

if((ifpt=fopen("client.txt","r")) == NULL)
{
printf("ERROR : File could not be opened\n");
exit(1);
}
if ((ofpt = fopen("newdata.txt", "w")) == NULL)
{
printf("ERROR : File could not be opened\n");
exit(1);
}
else
{
printf ("\nAccount\tName\t\tBalance\n");
fprintf (ofpt,"\nAccount\tName\t\tBalance\n");
}
for(i=0;i<8;i++)
{
fgets(s,59,ifpt);
sscanf(s,"%lf %s %lf", &account,&name,&balance);
sprintf(s,"%.2lf\t%s\t\t%0.2lf\n", account,name,balance);
puts(s);
fputs(s,ofpt);
}
fclose(ifpt);
fclose(ofpt);

getch();

system("pause");
return 0;
}