Menu ▾ ▴

strptime is not in time.h

Anonymous
2005-03-09
2026-11-10
  • Anonymous

    Anonymous - 2005-03-09

    I need to use the function strptime, which is usually in the include file "time.h", but doesn't appear to be in Dev-C++. I get a compiler error.

    Do I need to import another library or something? If so, how?

    Can anyone advise?
    Thanks

     
    • Nobody/Anonymous

      strptime() is not a standard library function. Which compiler and libraries system did you use, and what is the function supposed to do?
      Also, a google search on "strptime" might help.

      RaX

       
    • Anonymous

      Anonymous - 2005-03-09

      I'm converting a C program from linux to DOS. In linux it was compiled using Open Watcom, not sure what the lib system was. (glibc2?)

       
    • Stepho

      Stepho - 2005-03-09

      The strptime() function is not part of the C ISO standard, but is documented in the GNU C lib manual as part of the time functions. It parses a string and generates a time structure.
      The other date parsing function (getdate), is not part of the ISO C either, and not in the Dev-C++ package...

      http://www.gnu.org/software/libc/manual/html_node/Parsing-Date-and-Time.html

      I'm sorry, but I can't think of an other solution, as I never had to think about it.
      Anyway, if the format of your time strings is simple and known in advance (such if you know it's always "YYYY-mm-DD HH:MM:SS", you can easily parse it by your self.

       
    • Ian Walker

      Ian Walker - 2005-03-09

      strptime() is the reverse of strftime().

      It's job is to convert a string to a tm struct, using a format string.

      Unfortunately, it doesn't exist in MSVCRT.DLL, which I guess is why it is not provided in time.h.

      So if you need that functionality, you'll either need to write it yourself (!), or find another library that performs the same function.

      Have a look at the format string in your program, and compare it to http://www.osf.org/onlinepubs/007908799/xsh/strptime.html

      Chances are that your program might only be trying to convert a very small subset of this (perhaps time only, or dates in a particular format) and it shouldn't be too hard to code you own personal function that does just the conversion you need.

      In terms of libraries, I personally use the Boost date and time library (http://www.boost.org/doc/html/date_time.html) but I'm sure there are others. If you want Boost, then I have a DevPak at http://homepage.ntlworld.com/ian.walker25/boost_1.31.0.DevPak
      but be warned that it is a slightly old version, and was compiled and tested with Dev-C++ 4.9.9.1, and is quite a large download (9.3MB)

      Hope this helps,

      Ian W

       
    • Anonymous

      Anonymous - 2005-03-10

      Turns out I didn't need strptime() after all :D

      All I had to do was fill in mday, mon & year, and surprisingly mktime(&tm) filled in the rest correctly. ie. wday & yday.
      Don't know how or why, but it does. "Jimmy crack corn and I don't care."

      Thanks to all for the info and links...
      Cheers

       
  • Henry Tavet

    Henry Tavet - 2026-11-10

    Wracając z weekendu, postanowiłem zagrać na telefonie w coś dynamicznego, co cieszy się dobrą opinią wśród graczy na terenie Poland. Uruchomiłem fontancasino game bezpośrednio w przeglądarce mobilnej. Slot o tematyce starożytnej sypnął darmowymi spinami, a wygrana kwota okazała się bardzo przyjemnym dodatkiem do mojego budżetu.

     
  • Henry Tavet

    Henry Tavet - 2026-11-10

    W

     

    Last edit: Henry Tavet 2026-11-10

Log in to post a comment.