I would like for my program to capture a set number of data from a file ( the last 10 records to be exact ) so I have a Text file storing the following.
`File Created: Sun Mar 30 20:44:05 2014
1000 Deposit:100.00 Sun Mar 30 20:45:02 2014`
This is the following code I currently have:
typedef struct transaction
{
int acc_Id;
char *time;
char *type;
float amount;
}my_Trans;
int Dtl(Acc *user)// the user parameter is not used in the code as yet
{
my_Trans dtl_log[10];// to store the 10 information of my trans
FILE *dtl_fp;
int dtl_Cnd=1,x=0;
dtl_fp = Opnfile(acclg,r,dnt_ret_fp);// all this does is return my file for reading
while(dtl_Cnd)
{
fseek(dtl_fp,(sizeof(my_Trans))*(-1),SEEK_END);// I set my file cur to the end and start seeking trans size record;
fscanf(dtl_fp,"%d%s%.2f%s",&dtl_log[x].acc_Id,&dtl_log[x].type,&dtl_log[x].amount,&dtl_log[x].time);// read my trans records and store in my log ready to be displayed the x is just for test purposes to make sure i am getting the correct information out first
printf("%d",dtl_log[x].acc_Id);//check my information if it is the right thing
break;
}
}