Hello jasper hall,
There are several people here who can help, but without posting any code of what you have done it is unlikely you will find anyone willing to do the work for you.
First you have to help yourself. You say you have two files to read, so post the contents, or a fair sample, so that everyone can use the same information and see what has to be read.
Then post what code you have and point out any problems that you have.
First I would work on opening the files and reading from the files. Then you can decide if you want to store this information in something for later use or just read and process the file.
This is just one way you can deal with a file stream. It may not be the best, but I found it useful when learning to deal with files.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
#include <iostream>
#include <iomanip>
#include <string>
#include <limits>
#include <chrono>
#include <thread>
#include <fstream>
// --- Add any header files you create.
// <--- Constant global variables.
// <--- Prototypes.
int main()
{
// <--- Define variables. Just one option.
// <--- Your code here.
const std::string inFileName{ "" }; // <--- Put file name here.
std::ifstream inFile(inFileName);
if (!inFile)
{
std::cout << "\n File " << std::quoted(inFileName) << " did not open" << std::endl;
std::this_thread::sleep_for(std::chrono::seconds(3)); // <--- Needs header files "chrono" and "thread".
return 1; //exit(1); // If not in "main".
}
// <--- Code to read the files.
// <--- Keeps console window open. These lines may not be needed.
// <--- Keeps console window open when running in debug mode on Visual Studio.
// The next line may not be needed. If you have to press enter to see the prompt it is not needed.
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); // <--- Requires header file <limits>.
std::cout << "\n\n Press Enter to continue: ";
std::cin.get();
return 0;
}
|
You can add something to "inFileName" and "inFile" to distinguish which file it is working with.
The reason for leaving the program in the if block is if there is a problem it needs to be addressed before you continue with the program.
I would work on this part first because until you can read from the files the rest of the program is irrelevant until you have something to work with.
In the code lines 34 - 39 are optional. If you do not need them comment them or delete them.
Hope that helps,
Andy