Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 928765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:03:52+00:00 2026-05-15T20:03:52+00:00

I have a series of date strings in the format: 30-05-2001 string date1 =

  • 0

I have a series of date strings in the format: “30-05-2001”

string date1 = "30-05-2001";

I would like to parse the date into Day, Month, Year. Now an easy way
of doing this would be just to call the function sscanf. But I’d like to
explore other possiblilties and from searching the web the following
function from time.h was recommended:

char *strptime(const char *buf, const char *format, struct tm *tm); 

Does any anyone have experience using this function? Some short example would be
very helpful.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T20:03:53+00:00Added an answer on May 15, 2026 at 8:03 pm

    Just in case you want to understand how it works (no blackbox) or
    if you need the stuff to fly (no function calls) then here are a
    few tips for you:

    //             0123456789
    char date[] = "30-05-2001"; // DD-MM-YYYY
    int day, month, year;
    
    day = (date[0] - '0') * 10 + (date[1] - '0');
    month = (date[3] - '0') * 10 + (date[4] - '0');
    year = (date[6] - '0') * 1000 + (date[7] - '0') * 100 + (date[8] - '0') * 10 + (date[9] - '0');
    

    This (untested) code is clother to the right way to do what you
    wanted to do as it only does what you need to do (not more, not
    less). Safe, small, simple, FAST.

    If you are unsure of the date (user input) then you will have to
    check for its validity (or accept the idea to live with invalid
    dates in your application).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a series of performance tests I would like to show as a
I have a series of datetime objects and would like to calculate the average
i have a time series data like this: x <- structure(list(date = structure(c(1264572000, 1266202800,
I have a series of PDFs named sequentially like so: 01_foo.pdf 02_bar.pdf 03_baz.pdf etc.
I have a NSMutableArray I get by loading a plist into it. The date
I have an Array that returns a requested series of dates that I would
So I have a series of files with the following format Their real file
I have a series of urls tied to Django's generic date views. In the
I have a series of data that need to be written into SQL, what
I have a factored time series that looks like this: df <- data.frame(a=c(11-JUL-2004, 11-JUL-2005,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.