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;
	else cout << "Unable to open file";
	return 0;

I did try Using Google and Trial&Error but can't seem to work!

Thank You

Edited 5 Years Ago by SilentCoder: n/a

Well it shows how to read and write but not specific line. For example i want to change the fullscreen to 0 how would i do it?

This article has been dead for over six months. Start a new discussion instead.