For a project at college right now we need to create a program that reads in information from a text file and outputs it into an HTML file.
So i understand basically how to do it except that for the input parameters, we need to set up our program so that the user has the option of setting an output name or just using the name of the input text file. so i tried creating an if statement that basically says if the user enters in an optional name than create an ofstream that uses that name. The only problem with this is that then when i implement the ofstream later in the program, it doesnt recognize it because its declaration is in an if statement. So is there any way to alter an ofstream after it has already been declared?
//Filename input here
out.open(<filename>);//You can just use std::ofstream out(<filename>); instead of this and previous line
//If you need to change outout file