Hey guys i am new to c++ and i was practicing read/write specific line from an ini file.
My File
// browser ini file
// options
resolution 100 300
fullscreen 1
account "silentcoder"
My Code [Prints out the whole configuration file since my code said to do so]
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
using namespace std;
int main()
{
string line;
ifstream myfile ("file.ini");
if (myfile.is_open())
{
while (! myfile.eof())
{
getline (myfile,line);
cout << line << endl;
}
myfile.close();
}
else cout << "Unable to open file";
system("pause");
return 0;
}
I did try Using Google and Trial&Error but can't seem to work!
Thank You