I am having trouble outputting the data of my text file correctly. There are a few street addresses that have spaces in the street name, therefore it's causing the output to get all jumbled up.
Here is a look at two lines that are in my text file:
Note: Whenever I post this question... it doesn't do the text file justice on how well the text in it is evenly spread out.
Bob D Builder 123-456-7890
[email protected] 1234 N Wave Street, Atlanta, GA
Hump D Dumpty 098-654-3210
[email protected] 300 Always St, Buckeye, AZ
Here is a look at my code that I currently have:
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
int main()
{
ifstream file("ClientList.txt");
if(!file)
{
cout << "Error opening file." << endl;
}
string firstname;
string middleinitial;
string lastname;
string phone;
string email;
string address;
string city;
string state;
while(file >> firstname >> middleinitial >> lastname >> phone >> email >> address >> city >> state)
{
cout << firstname << " ";
cout << middleinitial << " ";
cout << lastname << " ";
cout << phone << " ";
cout << email << " ";
cout << address << " ";
cout << city << " ";
cout << state << endl;
}
return 0;
}