what is this line for

I am looking over a code for opening a file but i don't know what this line is for what is fstream fin

1
2
3
4
5
	std::fstream fin("script.txt", std::ios::in);
	if(fin.fail())
	{
		throw std::string("Unable to load the database: script.txt");
	}.
yeah fin is nowhere to be found but anyway thanks
*sigh* If you actually bothered to read the results you were getting about std::fstream, you'd understand.

std::fstream is a type.

fin is just the name of a variable of type std::fstream. Whoever wrote that bit of code could have given that variable any name - it was just their choice to call it fin.

Maybe to prevent confusion we should rename it. How about this?

1
2
3
4
5
6
std::fstream ProgramMaster("script.txt", std::ios::in);
	if(ProgramMaster.fail())
	{
		throw std::string("Unable to load the database: script.txt");
	}. 


Although maybe 'fin' stood for something like 'file in'?
Last edited on
Alright thank you i understand know thanks for the help
Topic archived. No new replies allowed.