Hey guys, my first post here.
I'm working on an assignment that basically has a list of Mail records (Name, address following the name) and need to figure out how to open this with a loop and the .substr() function. I've given it a fair shot, but I think it needs a few kinks ironed out. The main problem is that when I run it, nothing is displayed so I'm not sure how to approach the issue itself.
For any background context, the listRecords() function is used in a switch case where the user inputs that they want to see a list of the records.
Also provided are a list of the names which were added to the MailList.txt file through being appended.
Martin P Sanderson 8329 Madison Kansas City MO 64134
Samuel K. Roberts 4319 Oak Kansas City MO 64110
Eleanor M. Hutchinson 8814 Floyd Overland Park KS 66218
Jennifer Sue Bron 6824 Oxford Independence MO 64028
Jerry Lee Hovis 3015 Main Kansas City MO 64109
Mary Jo Serviss 2419 E. 89th St. Kansas City MO 64134
(EDIT) I know the spacing on this is an eyesore and I'm trying to find the fix to it, sorry!
I'm not sure if that gives any usefulness on the situation but I just want to make it clear as possible for any takers on this.. Anyway, I thank you for the read and any assistance you can provide!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
void listRecords()
{
ifstream iInput;
ofstream showMe;
string inputLine;
while (!iInput.eof())
{
showMe.open("MailList.txt",ios::app);
showMe << inputLine.substr(0, 10) << " "
<< inputLine.substr(4,24) << endl;
showMe.close();
getline(iInput, inputLine);
cout << inputLine << endl;
}
}
|