String

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Latina

    #1

    String

    If I am storing the date the user enters, how I can know what the
    month, day and year is.
    Ex: November 20, 2007
    Can some one help me to code that?
    Thanks
  • Christopher Pisz

    #2
    Re: String


    "Latina" <sdlt85@gmail.c omwrote in message
    news:a1896846-f25c-4d0b-9ee6-83151db8263f@d5 0g2000hsf.googl egroups.com...
    If I am storing the date the user enters, how I can know what the
    month, day and year is.
    Ex: November 20, 2007
    Can some one help me to code that?
    Thanks
    Well, one way is to refer to your favorite reference, and look up time_t,
    localtime, asctime, and other goodies found in the <ctimeheader. Another
    is to roll your own using std::string's find, erase, replace, substr, and
    other goodies found in the <stringheader . After you do that I am sure the
    folks here will be willing to help you with more specific questions, if you
    supply your best attempt at a compilable example.


    Comment

    • Victor Bazarov

      #3
      Re: String

      Latina wrote:
      If I am storing the date the user enters, how I can know what the
      month, day and year is.
      Ex: November 20, 2007
      Can some one help me to code that?
      Sure. How much are you willing to shell out? My rates are pretty high.

      V
      --
      Please remove capital 'A's when replying by e-mail
      I do not respond to top-posted replies, please don't ask


      Comment

      • alan

        #4
        Re: String

        On Nov 21, 10:35 pm, "Victor Bazarov" <v.Abaza...@com Acast.netwrote:
        Latina wrote:
        If I am storing the date the user enters, how I can know what the
        month, day and year is.
        Ex: November 20, 2007
        Can some one help me to code that?
        >
        Sure. How much are you willing to shell out? My rates are pretty high.
        I'll charge 80% of what Victor will charge (terms and conditions
        apply. see posters and print ads for details).

        Comment

        • Tadeusz B. Kopec

          #5
          Re: String

          On Tue, 20 Nov 2007 21:34:28 -0800, Latina wrote:
          If I am storing the date the user enters, how I can know what the month,
          day and year is.
          Ex: November 20, 2007
          Can some one help me to code that?
          Thanks
          Today is November 21, 2007.
          The code is

          std::cout << "November 21, 2007" << std::endl;

          No charge.

          --
          Tadeusz B. Kopec (tkopec@NOSPAMP LEASElife.pl)
          "Not only is God dead, but just try to find a plumber on weekends."
          -- Woody Allen

          Comment

          • Christopher

            #6
            Re: String

            On Nov 21, 12:14 pm, "Tadeusz B. Kopec" <tko...@NOSPAMP LEASElife.pl>
            wrote:
            On Tue, 20 Nov 2007 21:34:28 -0800, Latina wrote:
            If I am storing the date the user enters, how I can know what the month,
            day and year is.
            Ex: November 20, 2007
            Can some one help me to code that?
            Thanks
            >
            Today is November 21, 2007.
            The code is
            >
            std::cout << "November 21, 2007" << std::endl;
            >
            No charge.
            >
            --
            Tadeusz B. Kopec (tko...@NOSPAMP LEASElife.pl)
            "Not only is God dead, but just try to find a plumber on weekends."
            -- Woody Allen

            Lol. That is mean. I know we all assume it is a homework question, but
            it may just be a matter of the OP not knowing how to ask the question.
            We'll see if the OP can come back and rephrase the question properly.

            Comment

            • red floyd

              #7
              Re: String

              Christopher wrote:
              Lol. That is mean. I know we all assume it is a homework question, but
              it may just be a matter of the OP not knowing how to ask the question.
              We'll see if the OP can come back and rephrase the question properly.
              Having seen some of the OP's other posts, I'm assuming it's a homework.

              Comment

              • David Harmon

                #8
                Re: String

                On Tue, 20 Nov 2007 21:34:28 -0800 (PST) in comp.lang.c++, Latina
                <sdlt85@gmail.c omwrote,
                >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::istringstr eam, but I'd probably
                choose either my own splitter function or else boost::regex. For more
                on those topics see


                I would definitely consider std::map<std::s tring,intfor 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:



                Comment

                Working...