Cis170Cweek7Lab

Submitted by: Submitted by

Views: 68

Words: 607

Pages: 3

Category: Other Topics

Date Submitted: 09/05/2014 02:58 PM

Report This Essay

Lab 7 screenshot

Code for lab 7

// Name

// Create a C++ console application that will store and retrieve names and addresses in a text file.

//Specification: Append and display records in a address database

#include <iostream>

#include <fstream>

#include <string>

using namespace std;

void menu(void);

void writeData(void);

void readData(void);

string * split(string, char);

const char FileName[] = "c:/TestAddress.txt";

int main () {

menu();

return 0;

} //end main

void menu(void) {

char userChoice = ' ';

//allow user to choose to append records, display records or exit the program

cout << "(A)ppend Records, (S)how Records, (E)xit" << endl;

cin >> userChoice;

while (userChoice != 'e')

switch (userChoice)

{

case 'A':

case 'a':

{

writeData();

}

break;

case 'S':

case 's':

{

readData();

}

break;

default:

cout << "Invalid Choice" << endl;

break;

}

}//end menu

void writeData(void){

string name = " ";

string address = " ";

string city = " ";

string state = " ";

string zip = " ";

char response = 'Y';

ofstream outMyAddress("c://TestAddress.txt", ios::app);

outMyAddress.is_open();

do{

cout << "Append Records";

cout << endl;

getline(cin,name);

cout << "Name..... ";

getline(cin, name);

cout << "Street..... ";

getline(cin, address);

cout << "City..... ";

getline(cin, city);

cout << "State..... ";

getline(cin, state);...

More like this