On Tue, 20 Nov 2007 21:34:28 -0800 (PST) in comp.lang.c++, Latina
If I am storing the date the user enters, how I can know what the
month, day and year is.
Ex: November 20, 2007
There are many ways to attack that kind of problem, and no one
predefined "best" way. The biggest question is how much variability are
you prepared to accommodate in what the user has typed.
I would probably begin by splitting the string into the chunks you want
to look at. You might do that with std::istringstream, but I'd probably
choose either my own splitter function or else boost::regex. For more
on those topics see
http://groups.google.com/[email protected]
I would definitely consider std::map<std::string,int> for the job of
translating month names and abbreviations to the month number.
Remember, post your own attempt at solving the problem when asking
questions if you want people to take seriously your intention to learn.
See "[5.8] How do I post a question about code that doesn't work
correctly?" in Marshall Cline's C++ FAQ. It is always good to check the
FAQ before posting. You can get the FAQ at:
http://www.parashift.com/c++-faq-lite/