I am reading from a file (containing numbers seperated by newline) and calculating the amount. The problem is while reading the file and storing the amount in array it is skipping the first letter of the first amount, eg:- if the first line has 324, then it will read 24 and if the line has 3 then it will get junk vale but rest of the line is fine.
The code is
#include<graphics.h>
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
static int den[9]={1000,500,100,50,20,10,5,2,1};
void main()
{
clrscr();
unsigned long long amt[9];
unsigned long long temp=0,total=0;
int c=0,i=0,j=0,gd=DETECT,gm,x=66,y=22,font=8;
fflush(stdin);
FILE *fp;
fp=fopen("OPENCASH.TXT","r");
while((c=getc(fp))!=EOF)
{
fscanf(fp,"%llu",&amt[i]);
i++;
}
initgraph(&gd,&gm,"C:\\TC\\BGI");
settextstyle(font,HORIZ_DIR,1);
printf(" \t ");
for (i=0;j<50;j++)
{
printf("_");
}
outtextxy(x, y, " The Closing Cash Denomination");
printf("\n\n\n\t ");
for (i=0;i<50;i++)
{
printf("_");
}
font=5;
settextstyle(font,HORIZ_DIR,1);
x=30;
y=87;
outtextxy(x,y,"1000");
font=6;
settextstyle(font,HORIZ_DIR,1);
outtextxy(104,y,"X");
gotoxy(20,7);
printf("%llu",amt[0]);
outtextxy(205,--y,"=");
temp=den[0]*amt[0];
total=total+temp;
gotoxy(35,7);
printf("%llu",temp);
++y;
font=5;
x=42;
y=y+34;
outtextxy(x,y,"500");
font=6;
settextstyle(font,HORIZ_DIR,1);
outtextxy(104,y,"X");
gotoxy(20,9);
printf("%llu",amt[1]);
outtextxy(205,--y,"=");
temp=den[1]*amt[1];
total=total+temp;
gotoxy(35,9);
printf("%llu",temp);
++y;
font=5;
y=y+32;
outtextxy(x,y,"100");
font=6;
settextstyle(font,HORIZ_DIR,1);
outtextxy(104,y,"X");
gotoxy(20,11);
printf("%llu",amt[2]);
outtextxy(205,--y,"=");
temp=den[2]*amt[2];
total=total+temp;
gotoxy(35,11);
printf("%llu",temp);
++y;
font=5;
x=54;
y=y+31;
outtextxy(x,y,"50");
font=6;
settextstyle(font,HORIZ_DIR,1);
outtextxy(104,y,"X");
gotoxy(20,13);
printf("%llu",amt[3]);
outtextxy(205,--y,"=");
temp=den[3]*amt[3];
total=total+temp;
gotoxy(35,13);
printf("%llu",temp);
++y;
font=5;
y=y+31;
outtextxy(x,y,"20");
font=6;
settextstyle(font,HORIZ_DIR,1);
outtextxy(104,y,"X");
gotoxy(20,15);
printf("%llu",amt[4]);
outtextxy(205,--y,"=");
temp=den[4]*amt[4];
total=total+temp;
gotoxy(35,15);
printf("%llu",temp);
++y;
font=5;
y=y+34;
outtextxy(x,y,"10");
font=6;
settextstyle(font,HORIZ_DIR,1);
outtextxy(104,y,"X");
gotoxy(20,17);
printf("%llu",amt[5]);
outtextxy(205,--y,"=");
temp=den[5]*amt[5];
total=total+temp;
gotoxy(35,17);
printf("%llu",temp);
++y;
font=5;
x=64;
y=y+32;
outtextxy(x,y,"5");
font=6;
settextstyle(font,HORIZ_DIR,1);
outtextxy(104,y,"X");
gotoxy(20,19);
printf("%llu",amt[6]);
outtextxy(205,--y,"=");
temp=den[6]*amt[6];
total=total+temp;
gotoxy(35,19);
printf("%llu",temp);
++y;
font=5;
y=y+31;
outtextxy(x,y,"2");
font=6;
settextstyle(font,HORIZ_DIR,1);
outtextxy(104,y,"X");
gotoxy(20,21);
printf("%llu",amt[7]);
outtextxy(205,--y,"=");
temp=den[7]*amt[7];
total=total+temp;
gotoxy(35,21);
printf("%llu",temp);
++y;
font=5;
y=y+31;
outtextxy(x,y,"1");
font=6;
settextstyle(font,HORIZ_DIR,1);
outtextxy(104,y,"X");
gotoxy(20,23);
printf("%llu",amt[8]);
outtextxy(205,--y,"=");
temp=den[8]*amt[8];
total=total+temp;
gotoxy(35,23);
printf("%llu",temp);
y=y+9;
outtextxy(264,y,"___________");
y=y+27;
outtextxy(150,y,"Total Cash");
gotoxy(35,25);
printf("%llu",total);
getch();
}