I
i
HELLO SIR,
void debit_card(int n_,
int m_,
char ch_)
{
int de, pin, j, f;
long int g;
f=0;
g=100000;
//size_t i;
if((fp = fopen("debitCard.dat", "r+t"))==NULL)
{
printf("\nFile does not exist");
//exit(0);
}
printf("\nEnter debit card number and pin number");
scanf("%d%d", &de, &pin);
printf("\nConnecting to your Bank Server....");
do
{
g--;
}while(g!=0);
if(ch_ == 'b')
{
j = n_ * 6;
while(!feof(fp)&&!f)
{
fread(&d1, sizeof (struct debit), 1, fp);
if((de == d1.dc_n) && (pin == d1.p))
{
f=1;
if(d1.bal > j)
{
printf("\nTransaction Completed");
d1.bal =d1.bal-j;
fwrite(fp, sizeof (struct debit), 1, fp);
/*fread(&d1, sizeof (struct debit), 10, fp);
printf("%d",d1.bal);
fclose(fp);*/
clear(n_, m_, ch_);
receipt(n_, j);
break;
}
else if(d1.bal < 0)
{
printf("\nBalance below zero");
break;
}
else if(d1.bal < j)
{
printf("\nThere is no enough money");
break;
}
}
}
if(f==0)
{
printf("\nIncorrect format");
printf("\nRestart Transaction");
}
fclose(fp);
}
I can't update the files data.I get d1.bal from the file and do some
modification and update that .But the same data is retrieved from me
when i again run this program. Please solve this.
2nd question is.....
I want to display two answers .When i press the Enter key first
answer should be displayed and few seconds later the second answer
should be displayed. How can i do it?
void debit_card(int n_,
int m_,
char ch_)
{
int de, pin, j, f;
long int g;
f=0;
g=100000;
//size_t i;
if((fp = fopen("debitCard.dat", "r+t"))==NULL)
{
printf("\nFile does not exist");
//exit(0);
}
printf("\nEnter debit card number and pin number");
scanf("%d%d", &de, &pin);
printf("\nConnecting to your Bank Server....");
do
{
g--;
}while(g!=0);
if(ch_ == 'b')
{
j = n_ * 6;
while(!feof(fp)&&!f)
{
fread(&d1, sizeof (struct debit), 1, fp);
if((de == d1.dc_n) && (pin == d1.p))
{
f=1;
if(d1.bal > j)
{
printf("\nTransaction Completed");
d1.bal =d1.bal-j;
fwrite(fp, sizeof (struct debit), 1, fp);
/*fread(&d1, sizeof (struct debit), 10, fp);
printf("%d",d1.bal);
fclose(fp);*/
clear(n_, m_, ch_);
receipt(n_, j);
break;
}
else if(d1.bal < 0)
{
printf("\nBalance below zero");
break;
}
else if(d1.bal < j)
{
printf("\nThere is no enough money");
break;
}
}
}
if(f==0)
{
printf("\nIncorrect format");
printf("\nRestart Transaction");
}
fclose(fp);
}
I can't update the files data.I get d1.bal from the file and do some
modification and update that .But the same data is retrieved from me
when i again run this program. Please solve this.
2nd question is.....
I want to display two answers .When i press the Enter key first
answer should be displayed and few seconds later the second answer
should be displayed. How can i do it?