1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
#include<stdio.h>
#include<string.h>
int main()
{
short seq;
long ban;
long rank;
char ch;
long long a, b,c;
char bill_date[8];
char s_date[8];
char dump_bill_date[8];
char dump_bill_due_date[8];
FILE* fptr=NULL;
fptr=fopen("bill.txt","r");
while( fscanf(fptr,"%ld,%hu,%ld,%lld,%lld,%lld,%8s,%8s",&ban,&seq,&rank,&a,&b,&c,bill_date,s_date) != EOF )
{
printf( "dump_bill_date = %-.8s\n",dump_bill_date);
printf( "dump_bill_due_date = %-.8s\n",dump_bill_due_date);
printf( "Ban = %ld \n ",ban);
printf( "Seq = %hu \n",seq);
printf( "rank = %ld \n",rank);
printf( "a = %lld \n",a);
printf( "b = %lld \n",b);
printf( "c = %lld \n",c);
printf( "bill = %-.8s \n",bill_date);
printf( "s_date = %-.8s \n",s_date);
strncpy(dump_bill_date,bill_date,8);
strncpy(dump_bill_due_date,s_date,8);
printf( "dump_bill_date = %-.8s\n",dump_bill_date);
printf( "dump_bill_due_date= %-.8s\n",dump_bill_due_date);
}
fclose(fptr);
}
| |