read ini file

what can i do to read my program this ini file.

for example this is the content of my.ini:

a=1
b=2
Last edited on
Well, you could probably just do it this way:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
#include <ostream>
#include <string>

int main(void) {
     ostream Stream;
     string buffer;
     Stream.open("file.ini"); //or whatever the path is to your .ini file
     if(!Stream.is_open()) {
          cerr << "Error, file was unable to be opened.";
          return 0;
     }
     while(!Stream.eof()) {
          getline(Stream, buffer);
          //do stuff with buffer...
     }
     Stream.close();
     return 0;
}
Last edited on
thanks..
Topic archived. No new replies allowed.