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

What line of the file do you want to read?

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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.