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

Recommended Answers

All 5 Replies

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 developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.