Question: This is a c++ question. I am given a txt file with key value pairs. For example, each line will read something like cat 5000
This is a c++ question. I am given a txt file with key value pairs. For example, each line will read something like "cat 5000" or "dog 199" (without quotes). There are several lines with values like this. How can I read in these string and number values into a vector if, for example, I am given the code below to make the "sortData" function work?
class sortData
{
public:
//Required function to read file, make dictionary with values
sortData(string filename.txt);
private:
//class to store a string and number value.
class Data
{
public:
string s;
int number;
};
};
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
