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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:02:15+00:00 2026-05-31T13:02:15+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.

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 it keeps getting me segmentation Fault.(I’m putting this information into structures).

 for(i=0;i<check_enter;i++){
    sscanf(all_flights[i],
    "%d %d %d:%d%c %d:%d%c %s",
    &all_flights_divid[1].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_minute,
    &all_flights_divid[i].arrival_time_minute,
    &all_flights_divid[i].arrival_time_format,
    &all_flights_divid[i].frequency);

    printf("%d ",all_flights_divid[i].flight_number);
    printf("%d ",all_flights_divid[i].route_id);
    printf("%d ",all_flights_divid[i].departure_time_hour);
    printf("%d ",all_flights_divid[i].departure_time_minute);
    printf("%c ",all_flights_divid[i].departure_time_format);
    printf("%d ",all_flights_divid[i].arrival_time_hour);
    printf("%d ",all_flights_divid[i].arrival_time_minute);
    printf("%c ",all_flights_divid[i].arrival_time_format);
    printf("%s\n",all_flights_divid[i].frequency);
  }

This is how I declared it.

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

0 86 2 30 p 0 50 p Daily
0 17 10 40 a 0 15 p 5
0 86 3 10 p 0 30 p 1
0 48 6 25 a 0 30 a 156
0 100 10 15 a 0 30 p Daily
0 6 2 15 p 0 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-31T13:02:16+00:00Added an answer on May 31, 2026 at 1:02 pm

    Look carefully at your list of output targets in sscanf. Do you see the difference between &all_flights_divid[i].departure_time_minute and all_flights_divid[i].departure_time_format? Similary for .arrival_time_format and .frequency.

    What do you think the & ampersand is for? Hint: what is one way of returning multiple values from a single function call, and what does this have to do with the & ampersand?

    A segmentation fault arises when your program tries to write data into memory the operating system has never instructed the CPU to make available to the program. Segmentation faults do not always occur when data is misplaced, because sometimes data is misplaced within available memory. By way of analogy, if you inadvertently put a book in the wrong place on the bookshelf, you’ll not easily find the book later, but the book is still on a bookshelf and does not seem to anyone to be out of place. On the other hand, if you inadvertently put the same book in the refrigerator, well, when mother goes to get the milk she’s going to issue you a segmentation fault! That’s the analogy, anyway.

    In general, it is hard to guess whether misplacing data will cause a segmentation fault (as misplaced into the refrigerator) or not (as misplaced on the bookshelf) until you run the program. The segmentation fault (refrigerator) is preferable because it makes the mistake obvious, so the operating system tries to give you as many segmentation faults as it can by affording the program as little memory as possible.

    I am avoiding giving a 100 percent direct answer because of your “homework” tag. See if you cannot figure out the & ampersand matter, then come back here if it still does not make sense.

    • 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'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.