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

  • Home
  • SEARCH
  • 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 273001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T00:23:25+00:00 2026-05-12T00:23:25+00:00

Basically, I want to have my program retrieve various variables from the hard drive

  • 0

Basically, I want to have my program retrieve various variables from the hard drive disk for use in the program. I guess, before asking for details, I should verify that is even possible. Is it?

If it is, what is the best way? I’ve seen the use of .ini files, but I don’t know how to retrieve data specifically from .ini files. Is it the same as a text file that you have messed with to make sure variables will always be on x line? For instance:

ifstream variables("variables.ini");

//some code later
//assume line 'x' holds a variable

if(variables.good())
{
   variables.get(x);
}

//or whatever =/

I’m kind of at a loss for what to do here.

Edit: my language of choice is C++.

  • 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-12T00:23:25+00:00Added an answer on May 12, 2026 at 12:23 am

    The first questions you need to address are the who and the why. Your options on the how will follow from those.

    So who (or what) will be accessing the data? If it is just the program itself then you can store the data however you want – binary file, xml, database, ini file, whatever. However if the data needs to be easily accessible to the user so they can change it prior to a run then a text file like an ini, which can be easily edited, makes sense. In order to edit the data stored in other formats you may have to write an entirely separate program just to manipulate the stored parameters. Maybe that makes sense in your situation or maybe not but it will be more work.

    If you choose to go the ini route then you are on the right track. They are just text files. A common format is to have sections (usually in brackets), and then key/value pairs within the sections. Usually comment lines start with semicolon, a nice touch for the users who may want to flip back and forth between settings.

    So something like this:

    [System]
        datapath = /home/me/data
    
    [Application]
        start_count = 12
    ;   start_count = 20  //this is a comment
    

    You don’t have to worry about specific lines for your data. You just read through the file line by line. Empty or comment lines get tossed. You take note of what section you are in and you process the key/value pairs.

    There are many ways to store the parsed file in your program. A simple one may be to concatenate the section name and key into a key for a map. The value (of the key/value pair) would be the data for the map.

    So “Systemdatapath” could be one map key and its value would be “/home/me/data”. When your program needs to use the values it just looks it up by key.

    That’s the basics. Ultimately you will want to embellish it. For instance, methods to retrieve values by type. E.g. getString(), getInteger(), getFloat(), etc.

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

Sidebar

Ask A Question

Stats

  • Questions 196k
  • Answers 196k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I decided XPATH wasn't suited for what I wanted and… May 12, 2026 at 7:07 pm
  • Editorial Team
    Editorial Team added an answer The interesting part of this is that you're seeing a… May 12, 2026 at 7:07 pm
  • Editorial Team
    Editorial Team added an answer I asked a similar question a while back and found… May 12, 2026 at 7:07 pm

Related Questions

Is there any way by which i can find out free port on the
I'm writing an asp.net web app. and i've hit a bit of a brick
I want to extend a large C project with some new functionality, but I
I want to automate several tasks (eg. simulate eclipse style ctrl - shift -

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.