So I'm creating a program that lets me read a list from a file (Filled with Numbers), allow the user to update (erase, add) and change the starting sequence of numbers, finds all the unique combinations of three numbers in a sequence of numbers that add to a requested sum, use data validation for user entries, calculate and display statistics, and write out the final results to a file.
List example: 33,31,14,37,30,11,17,27,22,35,1,19,42
Serach sum = 33 there are 3 unique combinations
Question: How do I let the user edit the file and update it then pass it to the other search sum function.
My apologies. I want to know how to let the user edit vector in a loop until they are finished with editing then pass that info to search sum(find the unique combo) but I'm lost on how to to do that.
@lic14, all this stuff would be easier if contained in a class, and then each method would know about that class' private vector or stream variables.
As it is now, if you want more methods to know about something while keeping ownership in main() , then you'd need to add more parameters to those methods.
a) Give them ifstream or ofstream references, for example. An input file could be opened in main() (nothing read in just yet), and passed in to whatever needs it as ifstream& .
Or
b) give methods a (string) file name and allow them to fully control the opening/error handling, reading, and closing of the file.
Personally I'd have the input done only once (file or user input), but of course you can put in logic to re-read a file. If you're expecting lot of re-reads, then it may make sense to build something in the b) style.