I am very new to C++ and am taking a beginners course in college. We have a project due this coming tues. and I am stuck, I was wondering if you could please help me.
Background on proj:
I am working in the circulation dept of a magazine, and it is time to send out this month's magazines.
What I am supposed to do:
This program is supposed to read in a master file of subscribers, produce labels that will be organized into 4 groups, and then print out an updated subscriber file that will remove all the expired subscribers.
These are the criteria for the labels:
1. labels for all the subscriptions which have not expired and do not end this month
2. labels for all the subscriptions which expire this month i.e. have an expiration date equal to the first line in the input file.
3. labels for all the subscriptions which have expired
4. a list of all subscriptions which have not expired.
The master file looks like this:
07/10
John Brown 2020 K St. Ste 300 Washington, DC 2005208/12
Mary Poppins5678 Lexington Ave. New York, NY 1001207/10
Micky Mouse 1234 Buena Vista Dr.Los Angeles, FL 2000507/09
Bernard Shaw 62 Magnolia Ave. Dublin, Ireland 9932407/11
Joe-AllennMikleshevs76799 Congress Ave. Rowlings, Wyoming 6655407/10
Gloria Stephenson77665 La Salle St. Arlington, Virginia 2200107/11
Pamela Herby 89765 North Star St.Denver, Colorado 3322407/10
Zermillo Frankel 788 51st Street San Fransisco, CA 9001107/09
Betty White 33216 23rd Street Chicago, Illionis 4567807/12
Donald Duck 3344 Duck Pond Ln. Kansas City, MO 6532106/08
Alan Smith 1232 Cedar Avenue Rockville, MD 2084707/11
Jane Alexander 93473 Rainbow Ave. Raleigh, NC 2761407/10
where the first name (1-10), last name (11-20), address (21-40), city and state (41-50), 5 digit zip code (61-65), and expiration date (66-70...given in dd/dd which is year and then month) are given in columns.
This is what I have for the compiler to read in the txt file:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(){
string line;
ifstream myfile ("hw2.dat.txt"); //hw2 is the txt file which has the master file information
if (myfile.is_open())
{
while(! myfile.eof())
{
getline (myfile, line);
cout << line << endl;
}
myfile.close();
}
All this does is copy the master file and prints it the same way that I have it printed in this message.
However, after that I am not sure how to get the compiler to read the master file, line for line. I am thinking that the compiler is supposed to take each of those lines, make it into an array, and then read columns 66-70 and check it against the user-inputted year/month. But I don't know how to do that.
I know this is long, but could you please guide me as to what I should do? I am pretty desperate since my project is due tuesday and I would appreciate any help.
Thanks so much