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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started