Pin Authentication/ reading specific lines *help*
Nov 21, 2015 at 11:42pm UTC
Hi there all. I would just like to ask a question regarding reading specific lines from a file with the use of a "PIN number" keyword. After authentication would then use the following lines for name and account_type for print_account() to use.
This code is what I've been using to test out ideas for a bigger scale project
of mine, related to "banking accounts". Also a big problem of mine is using a Pin authentication
here is the txt file that I am using to read from
1 2 3 4 5 6 7 8 9 10 11 12
123 //Pin code
maggie //name
1 //account_type
456
dan
2
789
Rikko
1
Here is the code that I am using to test my ideas out. I currently have problems doing the read_account function and the pin authentication
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
//----------------------------------------------------
void Exit();
void print_account();
void create_account();
void read_account(int );
void write_file();
string name;
int account_pin;
int account_type;
//-----------------------------------------------------
void Exit(){
cout << "\n\nThank you for using this Program!\n\n" ;
}
void create_account(){ //creating account
cout << "Enter Account Pin: " ;
cin >> account_pin;
cin.ignore();
cout << "\nEnter Account Name: " ;
getline(cin, name);
cout << "\nEnter Account type(1 for credit, 2 for savings): " ;
cin >> account_type;
cout << "\n\nFinsihed creating account\n\n" ;
}
void print_account(){ //printing the account
cout << "Name: " << name;
cout << "Account type: " << account_type << "\n\n" ;
}
int main(){
int choice;
int pin; //pin authentication for account
do {
cout << "1.) Create Account\n" ;
cout << "2.) Print Account\n" ;
cout << "3.) Exit\n\n" ;
cout << "please enter a choice: " ;
cin >> choice;
switch (choice){
case 1:
write_file();
break ;
case 2:
cout << "Enter Pin: " ;
cin >> pin;
read_account(pin);
break ;
}
}while (choice != 3);
Exit();
return 0;
}
void write_file(){
ofstream outFile;
outFile.open("Info.txt" , ios::app);
create_account();
outFile << endl;
outFile << account_pin << " " ;
outFile << name << " " ;
outFile << account_type << " " ;
}
void read_account(int a){
ifstream inFile;
if (inFile.is_open()){
}
}
if there are any unclear spots that I have stated please, I urge you to ask.
Thank you Very Much!
Last edited on Nov 21, 2015 at 11:44pm UTC
Topic archived. No new replies allowed.