w5sdfig;olfkcgnxcb
/*
This program will use structs to store data about
accounts
*/
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;
const int SIZE = 16;
struct Cust
{
char name[SIZE];
char phone[SIZE];
float accountBal;
};
// Function Prototypes
// Function to enter new records into file.
// Function to display menu
void menu ();
void addCust(fstream&);
void displayAll(fstream&);
int main ()
{
char choice [4];
fstream custBinFile; // Filestream for I/O to Binary File
// Opening Binary File for Both input and output.
custBinFile.open("custBinFile.dat", ios::out|ios::in|ios::binary);
cout<< "Enter any choice from the above Menu List:"<<endl;
do
{
menu();
cin >> choice;
// If to handle adding a record to file
if((strcmp(choice, "A") == 0) || (strcmp(choice, "a") == 0))
{
addCust(custBinFile);
}
// Displaying one record from File
else if((strcmp(choice, "F") == 0)|| (strcmp(choice, "f") == 0))
{
cout << "Find and Display record \n" << endl;
}
custBinFile.read(reinterpret_cast<char *> (&custType), sizeof(custType));
cout << "Customer Name: " << custType.name << endl;
cout << "Customer Phone Number: " << custType.phone << endl;
cout << "Customer Account Balance: " << custType.accountBal << endl;
}
}