Thank you so much for your time and the informative post.
So I did not use getline() completely. I did some research online and thought that using substrings would be better. This is what my code looks like right now:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(){
string s, s1, s2, s3, s4, s5, s6, s7, date;
string yy, mm;
char slash;
ofstream outfile, expired, expiring, valid;
outfile.open("expired.txt");
outfile.open("expiring.txt");
outfile.open("valid.txt");
ifstream myfile;
myfile.open("hw2.dat.txt");
getline(myfile,date);
yy = date.substr(0,2);
mm = date.substr(3,2);
cout << yy << mm << endl;
while(! myfile.eof())
{
getline(myfile,s);
cout << s << endl;
s1 = s.substr(0,9);
cout << s1 << endl;
s2 = s.substr(10,9);
cout << s2 << endl;
s3 = s.substr(20,19);
cout << s3 << endl;
s4 = s.substr(40,19);
cout << s4 << endl;
s5 = s.substr(60,5);
cout << s5 << endl;
s6 = s.substr(65,2);
cout << s6 << endl;
s7 = s.substr(68,2);
cout << s7 << endl;
if (s6 < yy){
cout << "expired" << endl;
expired.txt << "s1 s2 s3 s4 s5 s6" << endl;
}
else if (s6 == yy && s7 < mm){
cout << "expired2" << endl;
//write to expired file s1 s2 s3 s4 s5 s6 s7;
}
else if (s6 == yy && s7 == mm){
cout << "expiring" << endl;
// write to expiring file s1 s2 s3 s4 s5 s6 s7;
}
else
cout << "OK" << endl;
//write to valid file s1 s2 s3 s4 s5 s6 s7;
}
return 0;
}
This code will run, however it will say that there is an unexpected error with runtime after it finishes running. Is there something wrong with my compiler or does the program have a bug?
I have two other questions also, if you could help me.
My first question is how do I put the seperated strings into three text documents, one for the expired, expiring, and not expired. As you can see in my code, I tried doing it but I don't think I did it right.
Also, I need to have an output which updates the subscriber list, getting rid of the expired subscribers.
Could you please guide me on how I should do that?
Thanks again so much for your time.