C++ How to get a variable from a file.ini?

Good evening.
A mission to obtain from a file a.ini variable. In the file except the value of a variable there's nothing else, just a number.
How it can be implemented?
int a = fopen ("a.ini", "r"); is not working.
June 14th 19 at 20:14
1 answer
June 14th 19 at 20:16
Well, nothing complicated, let's go the easiest way possible.
#include <fstream> //library file streams
#include <string>
using namespace std;

int main()
{
 int value;
 string line;
 fstream* fileStream;

 fileStream = new fstream("c:/file.ini"); //instaliram stream and pass to the constructor the path to the file
 getline(*fileStream, line); //read first line from file into string
 value = stoi(line); //convert string to int, here for Faches taste, as you like to convert

 printf("%d\n", value);

system("pause");
 return 0;
}</string></fstream>


PS.
This is the easiest method, and can be more complicated, just read the file and bitwise initialize int that way, but start with this. If you are interested in the theme of the bitwise reading/writing to a file, then Google flags about the file stream.

Find more questions by tags C++