root/bdm/libconfig/samples/c++/sample2.cpp @ 278

Revision 278, 1.0 kB (checked in by smidl, 15 years ago)

props

  • Property svn:eol-style set to native
Line 
1/*************************************************************************
2 ** Sample2
3 ** Load sample.cfg and access the "values" array
4 *************************************************************************/
5
6#include <iostream>
7#include <libconfig.h++>
8
9using namespace libconfig;
10using namespace std;
11
12/***************************************************************************/
13
14int main()
15{
16  Config cfg;
17  try
18  {
19    /* Load the configuration.. */
20    cout << "loading [sample.cfg]..";
21    cfg.readFile("sample.cfg");
22    cout << "ok" << endl;
23
24    // Display the "values" array
25    cout << "display the \"values\" array..";
26    Setting& s = cfg.lookup("values");
27    long value1 = s[0];
28    long value2 = s[1];
29    cout << "[" << value1 << "," << value2 << "]..";
30    cout << "ok" << endl;
31
32    cout << "Done!" << endl;
33  }
34  catch (...)
35  {
36    cout << "failed" << endl;
37  }
38
39  return 0;
40}
41
42
43/***************************************************************************/
Note: See TracBrowser for help on using the browser.