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 7648127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:38:11+00:00 2026-05-31T10:38:11+00:00

I’m having a hard time using sscanf to scan hour and minutes from a

  • 0

I’m having a hard time using sscanf to scan hour and minutes from a list. Below is a small snip of the list.

1604 124 12:05p 1:21p Daily
1605 124 1:20p 2:40p Daily
1606 173 3:15p 4:38p Daily
1607 173 4:20p 5:43p Daily
1608 124 8:20p 10:00p Daily
1609 124 9:00p 10:37p Daily
1610 173 8:40a 10:05a Daily
1611 124 10:50p 12:20a Daily
1701 17 9:25a 1:00p Daily
1702 17 10:10a 1:45p Daily
1703 86 1:55p 5:15p Daily
1704 86 2:30p 5:50p Daily
1711 17 10:40a 2:15p 5
1712 86 3:10p 6:30p 1
1731 48 6:25a 9:30a 156
1732 100 10:15a 1:30p Daily
1733 6 2:15p 3:39p Daily

I’ve tried this, but for some of the time it is dropping the zero, which is very important.(I’m putting this information into structures).

    put_flights_into_array(int size){

      int i,check_enter,x,c;

      check_enter=0;
      x=0;

      /*Puts the temp_flights to all_flights*/

      for (i=0;i<size;i++){
        if(temp_flights[i] == '\n'){
          all_flights[check_enter][x]='\0';
          check_enter++;
          x=0;
        }else{
          all_flights[check_enter][x]=temp_flights[i];
          x++;
        }
      }

      /*Puts all_routes into proper structures*/

      for(i=0;i<check_enter;i++){
        sscanf(all_flights[i],
        "%d %d %d:%d%c %d:%d%c %s",
        &all_flights_divid[i].flight_number,
        &all_flights_divid[i].route_id,
        &all_flights_divid[i].departure_time_hour,
        &all_flights_divid[i].departure_time_minute,
        &all_flights_divid[i].departure_time_format,
        &all_flights_divid[i].arrival_time_hour,
        &all_flights_divid[i].arrival_time_minute,
        &all_flights_divid[i].arrival_time_format,
        &all_flights_divid[i].frequency);
        }

This is how I declared my structure.

struct all_flights{
  int flight_number;
  int route_id;
  int departure_time_hour;
  int departure_time_minute;
  char departure_time_format;
  int arrival_time_hour;
  int arrival_time_minute;
  char arrival_time_format;
  char frequency[10];
};
struct all_flights all_flights_divid[3000];

These are the results I get. Notice how at 1604 the time is 12 5, it should be 12 05, What happen to the zero before the five? Also same thing happen at 1609, the first zero disappeared.

1604 124 12 5 p 1 21 p Daily
1605 124 1 20 p 2 40 p Daily
1606 173 3 15 p 4 38 p Daily
1607 173 4 20 p 5 43 p Daily
1608 124 8 20 p 10 0 p Daily
1609 124 9 0 p 10 37 p Daily
1610 173 8 40 a 10 5 a Daily
1611 124 10 50 p 12 20 a Daily
1701 17 9 25 a 1 0 p Daily
1702 17 10 10 a 1 45 p Daily
1703 86 1 55 p 5 15 p Daily
1704 86 2 30 p 5 50 p Daily
1711 17 10 40 a 2 15 p 5
1712 86 3 10 p 6 30 p 1
1731 48 6 25 a 9 30 a 156
1732 100 10 15 a 1 30 p Daily
1733 6 2 15 p 3 39 p Daily
  • 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-31T10:38:13+00:00Added an answer on May 31, 2026 at 10:38 am

    the problem isn’t with the scanning, it’s with the printing. if you use a format like this

    printf("%02d", n);
    

    that zero will make sure there is a leading zero like you want

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
We're building an app, our first using Rails 3, and we're having to build
Does anyone know how can I replace this 2 symbol below from the string
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am currently running into a problem where an element is coming back from

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.