i have here 2 program the first one #include<stdio.h>

#include<conio.h>
#include<stdlib.h>
#include<process.h>

struct record{
char acc_name[6];
int pin;
float bal;
};
void main()
{
FILE *fp;

struct record b;
clrscr();

if((fp=open("accounts.dat","wt"))==0)
{
printf("Error");
exit(1);
}

printf("Enter account name:");
gets(b.acc_name);
printf("Enter account pin:");
scanf("%d",&b.pin);
printf("Enter balance:");
scanf("%f",&b.bal);

fprintf(fp,"%s %d %.2f",b.acc_name,b.pin,b.bal);
fclose(fp);
}

it lets user enter data and eventuallly store them in .dat file. this is a file handling in binary mode.
and the other one is this

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<process.h>
#include<dos.h>

void main()
{
FILE *fp;
char key,opt,ex,acc_name,x,y,z;
float amt_dep,amt_with,bal;
int pin;

fp=fopen("accounts.dat","r");
if(fp==NULL)
{
printf("Error");
exit(1);
}

clrscr();
printf("Account name:");
scanf("%s",&acc_name);
while(&fread(&b,sizeof(record),1,fp)!=NULL)
{b.acc_name=x;
if(acc_name=x)
{
printf("account name accepted!");
}
else{printf("invalid account!");}
}}
printf("Enter PIN:");
scanf("%d",&pin);
while(&fread(&b,sizeof(record),1,fp)!=NULL)
{printf("access granted!");
goto menu_dep;
}
else{
printf("Access denied!");}

menu:
{
printf("[1] balance inquiry");
printf("[2] deposit");
printf("[3] withdraw");

opt=getche();
}
switch(opt);
{
case '1':

{
clrscr();
printf("balance inquiry");
while(&fread(&b,sizeof(record),1,fp)!=NULL)
printf("your current balance is:%.2f",b.bal);
printf("another transaction?([y]/n)");
ch=getch();
if(ch=='Y'||ch=='y')
{
goto menu;
}

clrscr();
{
case '2':

clrscr();
printf("amount to deposit:P");
scanf("%f",&amt_dep);
while(&fread(&b,sizeof(record),1,fp)!=NULL)
{
b.bal=z;
z=amt_dep+z;
printf("your balance now is P%.2f",z);}
printf("another transaction?([y]/n)");
ch=getch();
if(ch=='Y'||ch=='y')
{
goto menu;
}
clrscr();
}
case'3':
{clrscr("amount to withdraw: P");
scanf("%f"&amt_with);
while(&fread(&b,sizeof(record),1,fp)!=NULL)
z=z-amt_with;
if(amt_with>z)
{
printf("Isuficient balance!");
}
else{printf("thank you! ");}
printf("another transaction?([y]/n)");
ch=getch();
if(ch=='Y'||ch=='y')
{
goto menu;
}
clrscr();
}
fclose(fp);
}

it is the atm program, it lets user input an account name if the account name did not match in the data yuo have previously typed in the first program it displays invalid account. my problem now is how can i match the data i input in the second program in the data stored in the first program. pls help me. i need this on wednesday.
and we only use the printf scanf version not the cin and cout.thank you!!

read on string handling.
U are declaring a char to store a string. U are using

if(acc_name=x){}

whereas your intention is to compare string. The above statement is an assignment and the value will be true if the assignment was successful.
Read how to read and compare strings.

i have here 2 program the first one #include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<process.h>

struct record{
char acc_name[6];
int pin;
float bal;
};
void main()
{
FILE *fp;

struct record b;
clrscr();

if((fp=open("accounts.dat","wt"))==0)
{
printf("Error");
exit(1);
}

printf("Enter account name:");
gets(b.acc_name);
printf("Enter account pin:");
scanf("%d",&b.pin);
printf("Enter balance:");
scanf("%f",&b.bal);

fprintf(fp,"%s %d %.2f",b.acc_name,b.pin,b.bal);
fclose(fp);
}

it lets user enter data and eventuallly store them in .dat file. this is a file handling in binary mode.
and the other one is this

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<process.h>
#include<dos.h>

void main()
{
FILE *fp;
char key,opt,ex,acc_name,x,y,z;
float amt_dep,amt_with,bal;
int pin;

fp=fopen("accounts.dat","r");
if(fp==NULL)
{
printf("Error");
exit(1);
}

clrscr();
printf("Account name:");
scanf("%s",&acc_name);
while(&fread(&b,sizeof(record),1,fp)!=NULL)
{b.acc_name=x;
if(acc_name=x)
{
printf("account name accepted!");
}
else{printf("invalid account!");}
}}
printf("Enter PIN:");
scanf("%d",&pin);
while(&fread(&b,sizeof(record),1,fp)!=NULL)
{printf("access granted!");
goto menu_dep;
}
else{
printf("Access denied!");}

menu:
{
printf("[1] balance inquiry");
printf("[2] deposit");
printf("[3] withdraw");

opt=getche();
}
switch(opt);
{
case '1':

{
clrscr();
printf("balance inquiry");
while(&fread(&b,sizeof(record),1,fp)!=NULL)
printf("your current balance is:%.2f",b.bal);
printf("another transaction?([y]/n)");
ch=getch();
if(ch=='Y'||ch=='y')
{
goto menu;
}

clrscr();
{
case '2':

clrscr();
printf("amount to deposit:P");
scanf("%f",&amt_dep);
while(&fread(&b,sizeof(record),1,fp)!=NULL)
{
b.bal=z;
z=amt_dep+z;
printf("your balance now is P%.2f",z);}
printf("another transaction?([y]/n)");
ch=getch();
if(ch=='Y'||ch=='y')
{
goto menu;
}
clrscr();
}
case'3':
{clrscr("amount to withdraw: P");
scanf("%f"&amt_with);
while(&fread(&b,sizeof(record),1,fp)!=NULL)
z=z-amt_with;
if(amt_with>z)
{
printf("Isuficient balance!");
}
else{printf("thank you! ");}
printf("another transaction?([y]/n)");
ch=getch();
if(ch=='Y'||ch=='y')
{
goto menu;
}
clrscr();
}
fclose(fp);
}

it is the atm program, it lets user input an account name if the account name did not match in the data yuo have previously typed in the first program it displays invalid account. my problem now is how can i match the data i input in the second program in the data stored in the first program. pls help me. i need this on wednesday.
and we only use the printf scanf version not the cin and cout.thank you!!

may i know the output of this ATM program ?? .. our final exam for tom. is to make a Simple ATM program using Turbo C data base. asap ! tNx!

commented: Pure junk +0
commented: I guess by tomorrow, there will be one less wannabe programmer - WOOHOO!!!!!!!! -4

may i know the output of this ATM program ?? .. our final exam for tom. is to make a Simple ATM program using Turbo C data base. asap ! tNx!

So you decided to cheat your way trough class by googling "ATM C++" and you ended up here. And now you're even too lazy to compile the code and find out what the output is? How on earth do you think you're going to pass this class with that kind of attitude?

Next time start here and go here.

commented: "next time"? Surely you jest!, they've already failed so I doubt they'll be back. +19
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.