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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:10:55+00:00 2026-06-05T17:10:55+00:00

In context – I’m writing a simple, standalone config file parser for a class

  • 0

In context – I’m writing a simple, standalone config file parser for a class that will go into a larger program. I understand that there are extremely effective libraries (such as BOOST) to do this for me, but the class must be strictly stand-alone (no external libraries).

So, I have a config file that may look a little like this:

output_file : some_output_file.root
input_file : input_file.txt
potential_file :

Notice that the potential_file entry is blank, and should be read as such.

I intend to use fscanf, with a format specifier

fscanf(cfg_file,"%s : %s\n",flag,value);

However, what happens in the case of the potential_file flag? Will the character string value be empty? Or will fscanf try to read the next available string in the file?

  • 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-06-05T17:10:58+00:00Added an answer on June 5, 2026 at 5:10 pm

    You should check return value of fscanf. It returns the number of arguments successfully parsed. It will not make an empty string for you if you have no space after colon in 3rd line as per pattern. It will stop parsing in that case. If you want to play safe with no extra checks, initialize value before fscanf.

    %s implies reading of subsequent characters until a whitespace is found. The latter is defined as blank, newline, or tab. So it will not jump to next line.

    Also consider some library for config since you’ve tagged your questions in this way. YAML is easy to read and it has C bindings.

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

Sidebar

Related Questions

context: im writing a favicon parser: http://plugins.trac.wordpress.org/browser/wp-favicons/trunk/includes/class-http.php and http://wp.leau.co/2011/03/18/handling-redirects-for-wp-favicons-with-redirects-set-to-0-with-wordpress-wp_remote_get/ I saw : http://www.foxfilm.nl/favicon.ico in
(context)I have information from a bunch of elements that I'm collecting into a JSON
CONTEXT: I'm currently developing a website that will involve Credit Card numbers handling. Confidential
Context I want to use JavaFx with clojure. I am aware of http://nailthatbug.net/2011/06/clojure-javafx-2-0-simple-app/ Question:
Context If I want Lein 1.7 to start out with a particular class loaded,
Context: Windows7, optionally MinGW I'm thinking of writing a Tk interface for Lhogho .
Context: I'm making a simple solar system simulation in c++/OpenGL. Research: I've tried searching
Context: The structure of the code is that a WCF service (server-size) talks to
Context.startService Intent intent = new Intent(context, MyService.class); context.startService(intent); PendingIntent.getService Intent intent = new Intent(context,
Context I use FINDSTR /C:portid= scanports.xml to extract theses lines from a file: <port

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.