Unable to read INI file Parsing using boost::program_options
<p>I am a newbie in c++ and boost. I am attempting to read (later write) to INI file using boost::program_options. I even tried using boost::property_tree. </p>

<p>Both(program_options &amp; property_tree) work perfectly when std::stringstream s("[test]\n""a=2\n""b=3\n") is used, BUT NOT when std::ifstream s("dimension.ini"). I have put files: dimension.ini, Rcasdim.hpp/cpp in the same folder, and also have relevant boost lib files in search directory.</p>

<pre><code>INI File

[Section]

a=2

b=3

Purpose:  
I need to dynamically set the "Value" (at the start ONLY) for a Particular "Key" in INI file &amp; Later USE that Previously set "Value" for that "Key" by other project files (more, as a toggle)

 #include boost/program_options/detail/config_file.hpp

 #include boost/program_options/parsers.hpp


namespace pod = boost::program_options::detail;

class CRcasdim
{
    public:
    CRcasdim(){};
    ~CRcasdim(){};
    std::string getrcasdim(float);

    private:
    std::string sd;
};

std::string CRcasdim::getrcasdim(float d)

{

    //std::stringstream s("[Section]\n""a=2\n""b=3\n"); WORKS

    std::ifstream s("dimension.ini"); DOESNT WORK

    if(!s)
    {
        std::cerr&lt;&lt;"error"&lt;&lt;std::endl;
    }

    std::set&lt;std::string&gt; options;
    std::map&lt;std::string, std::string&gt; parameters;

    options.insert("Section.a");
    options.insert("Section.b");

try

{

    for (pod::config_file_iterator i(s, options), e ; i != e; ++i)

        parameters[i-&gt;string_key] = i-&gt;value[0];   
}

catch(std::exception&amp; e)

{
std::cerr&lt;&lt;"Exception: ";
}

    if (d==2)
    sd = parameters["Section.a"];

    else if (d==3)
    sd = parameters["Section.b"];

    return sd;
}
</code></pre>
