I know that the .txt file is being opened correctly, however, I don't know why the getline function is not storing the first line and outputting it correctly.
//Joseph Yong
//CSC2430
//Homework 7
//Main File
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include "Customer.h"
using namespace std;
Customer cust;
string blank = " ";
string line;
int start, end, count;
string titl, firstNam, middleNam, lastNam, add, cit, stat, zip, phone;
int main()
{
ifstream fileIn;
fileIn.open("Address1.txt");
if(fileIn.fail())
cout << "Failure to open file.\n\n";
getline(cin, line);
cout << line;
start = 0;
end = line.find(blank, start);
count = end - start;
titl = line.substr(start, count);
cust.setTitle(titl);
cust.getTitle();
cust.displayLabel(cout);
fileIn.close();
return 0;
}
//Joseph Yong
//CSC2430
//Homework 7
//Implementation File
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include "Customer.h"
using namespace std;
Customer::Customer()
{
}
void Customer::setTitle(string titl)
{
title = titl;
}
void Customer::setName(string firstNam, string middleNam, string lastNam)
{
firstName = firstNam;
middleName = middleNam;
lastName = lastNam;
}
void Customer::setAddress(string add, string cit, string stat)
{
streetAdd = add;
city = cit;
state = stat;
}
void Customer::setZip(string zip)
{
zipCode = zip;
}
void Customer::setPhone(string phone)
{
phoneNum = phone;
}
string Customer::getTitle()
{
return title;
}
string Customer::getFirstName()
{
return firstName;
}
string Customer::getMidName()
{
return middleName;
}
string Customer::getLastName()
{
return lastName;
}
string Customer::getStreetAdd()
{
return streetAdd;
}
string Customer::getCity()
{
return city;
}
string Customer::getState()
{
return state;
}
string Customer::getZip()
{
return zipCode;
}
string Customer::getPhone()
{
return phoneNum;
}
void Customer::displayLabel(ostream &out)
{
out << title;
}
Any ideas? Thanks~!