class

Mar 19, 2014 at 2:06pm
Guys i,m new in c++ so any body help to solve my problem i want to use file in this programme to store data so any one help me?


#include<iostream>
#include<string.h>
#include<conio.h>
using namespace std;
class acc{
int obj;
private:
int acc_no;
float balance;
int deposit;
int withdraw;
char name[18];
char ch[20];
public:
void input (){
cout<<"Enter your Account No:";
cin>>acc_no;
start:
cout<<"\nFor your Account security:\nPlease enter your name:";
cin>>(name);

if (stricmp(name,"umair")==0) {cout<<"\nok";}
else {cout<<"\nYou are entering the wrong name:";}
//goto start;
cout<<"\nWhat you want to do Deposit or Withdraw:";

cin>>ch;
if (stricmp(ch,"deposit")==0) {cout<<"\nYour previous amount is 5500:";
cout<<"\nHow much money you want to deposit:";
cin>>deposit;
cout<<"\nYour total amount is:"<<5500+deposit;}
if (stricmp(ch,"withdraw")==0) {cout<<"\nYour previous amount is 5500:";
cout<<"\nHow much money you want to withdraw:";
cin>>(withdraw);
cout<<"\nYour total amount is:"<<withdraw-5500;}


else {cout<<"\nYou entered the wrong word";}
}
};
int main (){
acc obj;
obj.input();

getch();
}
Mar 19, 2014 at 2:30pm
Please use code tags when posting code.
http://www.cplusplus.com/articles/jEywvCM9/


An example of writing to a file: http://www.cplusplus.com/reference/fstream/ofstream/ofstream/
Mar 19, 2014 at 5:37pm
Also, there's a tutorial on this site:

http://www.cplusplus.com/doc/tutorial/files/
Mar 20, 2014 at 5:43pm
mikeyboy help me to solve my problem i,m not understanding that how to use file
Mar 20, 2014 at 5:47pm
Do you know how to use streams for I/O ? If not, I recommend you read this tutorial first:

http://www.cplusplus.com/doc/tutorial/basic_io/

Once you've understood that, the one on files will make more sense.
Mar 20, 2014 at 6:19pm
yes i know but the problem is that i want to use file handling to store the once user enter data then programme store the entered data
Last edited on Mar 20, 2014 at 6:24pm
Mar 20, 2014 at 7:53pm
You have to decide what to write and in what format. You have to know the format in order to read from the file too.
Topic archived. No new replies allowed.