That's good in two respects, first that it did what you wanted,but perhaps more important, that you understood it - that means you should be able to modify or re-use these ideas later.
One additional thought, for real-world use, rather than hard-coding the filenames in the program, you may want to read them from the command line. Then perhaps execute the program from a bat file or script.
That will be another can of worms to open that I'm not sure if I am ready to tackle as of now. I am modifying it now just adding checks to make sure the file was in the directory and opened, also that it completed writing the file.
I will have to dig into the bat file and script to see what all it in tells.
I'm sure you will see me posting here again in the near future.
No worries. I wasn't trying to open a can of worms, rather I was thinking of ways to make it simpler and quicker for you to get from a to b. Leave that for some other time, when or if you feel a need for it.
My version. It may be flawed, just consider it a first attempt.
I did notice a problem which causes loss of data.
The input data is converted from a string to a double.That's ok. But when writing to the output file, the default precision may discard some digits, for example 1502.491 may appear as 1502.49 or 1502.397 may appear as 1502.4
In order to remedy this, before writing any data to the output file, set the required precision, something like this:
fout.precision(10); // do this after opening output file, to avoid loss of accuracy
Note also that the meaning of precision changes, if changing to fixed format. See docs.
That can of worms. A function takes ideally a stream. It does not open it. Now the caller can choose to pass cin or fstream, i.e program can be smart enough to read both from pipe and file. The reader function should not care.
I noticed the same thing yesterday Chervil when I started QC'n the data and validating between the values. No wonder I couldn't get the precision to work due to I had never worded with fout.precision(). I will work on implementing that.
Could you point me in the direction of how to convert to say a .bat or script? I see where it could be a problem if I were to run this on my own computer and not have a D:\JOBS\ directory. Much rather not hard coding in the path, which y'all had stated earlier. Was just trying to take the code a step at a time to not overwhelm myself, and to actually be able to learn and follow along. Thanks.
Well, I'm still trying to keep things fairly simple.
I was thinking along the lines of passing the file names as parameters to the program. I dare say this is not exactly what you were thinking of, but I'll at least show my idea. This is in terms of a windows OS