i used this codes to enter records at a file:
i input accountno, accountpin, and balance thrice and respectively: and account.dat contains:Code:fp=fopen("account.dat","w+"); clrscr(); for(x=0; x<3; x++) { printf("\nEnter account number: "); scanf("%s",&record[x].accountno); printf("\nEnter PIN: "); scanf("%s",&record[x].accountpin); printf("\nEnter initial balance: "); scanf("%d",&record[x].balance); for(y=0; y<5; y++) fprintf(fp,"%c",record[x].accountno[y]); fprintf(fp," "); for(y=0; y<4; y++) fprintf(fp,"%c",record[x].accountpin[y]); fprintf(fp," "); fprintf(fp,"%d\n",record[x].balance); }and in another program, i used fscanf to load up the records... but some special characters appear in part of record[x].accountpin,abcde 1234 2000
fghij 5678 4000
klmno 9012 6000
http://i35.photobucket.com/albums/d1...vin/cerror.jpg
help me pls, how can i load up my records w/o any errors? as you can see in the image, accountpin merge with accountno, and it contains some special character, and i dont know why...Code:fp=fopen("account.dat","r+"); clrscr(); for(x=0; x<3; x++) { fscanf(fp,"%s",&record[x].accountno); fscanf(fp,"%s",&record[x].accountpin); fscanf(fp,"%d",&record[x].balance); printf("%s %s %d \n",record[x].accountno,record[x].accountpin,record[x].balance);}



LinkBack URL
About LinkBacks



I used to be an adventurer like you... then I took an arrow to the knee.