Using Dev C++, we are trying to get the code to read it one line at a time and store it in an array. We don't seem to get any official errors, but a windows box pops onto the screen to find a solution for the errors?
#include <iostream>
#include <fstream>
#include "AddressBook.h"
const int ADDR_BOOK_SZ = 1000;
void AddNewAddressBook(AddressBook* current);
void PrintAddresses(AddressBook* addrBook);
using namespace std;
int main(int argc, char** argv) {
AddressBook addrBook[ADDR_BOOK_SZ];
AddressBook* current;
char* path;
ifstream file;
char* placeholder;
bool running = true;
char entered;
while(running) {
//print directions
cout << "a) Open an address book file\n"
<< "b) Add a new address book entry\n"
<< "c) Print the contents of current address book\n"
<< "d) Quit" << endl;
//get the user's command
cin >> entered;
//set pointer to the current addressbook
current = addrBook + AddressBook::entryCnt_;
if(entered == 'a') {
cout << "Please enter the file path for the address book file: " << '\n';
cin >> path;
file.open(path);
int i = 0;
while(!file.eof()){
//getline(placeholder, 100);
file >> placeholder;
addrBook[i].SetFirstName(placeholder);
file >> placeholder;
addrBook[i].SetFirstName(placeholder);
file >> placeholder;
addrBook[i].SetStreetNum((int)placeholder);
file >> placeholder;
addrBook[i].SetStreetName(placeholder);
file >> placeholder;
addrBook[i].SetCity(placeholder);
file >> placeholder;
addrBook[i].SetState(placeholder);
file >> placeholder;
addrBook[i].SetZipCode((int)placeholder);
i++;
}
}
else if(entered == 'b') {
current->AddEntryFromConsole();
}
else if(entered == 'c') {
for(int i = 0; i < AddressBook::entryCnt_; i++) {
addrBook[i].PrintToConsole();
}
}
else if(entered == 'd') {
return 0;
}
else {
cout << "Wrong input entered. Try again." << endl;
}
}
file.close();
}
Thank you for any and all help!