I just posted below what I have so far. I am on my last function of this program before I tackle main. I must say I am pretty proud of myself for writing 500 lines of code and not asking on here or google till now .
What I am trying to do it compare the computers date with what birthday in the <list>, which are all strings. Here is what I was thinking, using <sstream> and converting the string to an int. However it sounds great till I notice it will be one solid int and not day,month,year, hummmm.
I would like to iterate the list, convert them to three separate int's (day,month,year) push them into new list of int's and compare them in the if statement against the computers date.
Code:
void addressbook::GenBirthdayCards()
{
struct ConvertDate
{
int month,day,year;
};
for (std::list<MyaddressBook>::iterator it = Mylist.begin(); it!=Mylist.end(); ++it) {
it->DOB;
}
time_t t = time(0); // get time now
struct tm * now = localtime( & t );
if (now->tm_mon +1 && now->tm_mday && now->tm_yday + 1900 ==) {
//this is where I noticed I have an issue
}
}
Code:
#ifndef __addressBook__
#define __addressBook__
#include <iostream>
#include <string>
#include <list>
struct MyaddressBook {
std::string firstName;
std::string lastName;
std::string address;
std::string aniversary;
std::string DOB;
};
class addressbook {
private:
std::list<MyaddressBook> Mylist;
public:
addressbook();
~addressbook();
void addContact(MyaddressBook&);
void readfile(std::ifstream&,MyaddressBook&);
void updateFile(MyaddressBook&);
void EditNameOrDate();
void PrintAddressBook();
void GenBirthdayCards();
void GenAnnCard();
void deleteContact(std::string);
void sortContacts();
void ExitProgram();
};
#endif