I am novice to STL. can anyone pls help me in understanding how to create a list from an input file.
for example say we have a input file having employees name on our disk. How can we use this file to create a list of name?
std::list< std::string > employeenames;
std::string name;
while( /* loop until EOF */ )
{
// ... read one name from the file, store it in 'name'
employeenames.push_back( name );
}
Hopefully, the OP understands that list is a specific kind of STL container. Sometimes people use the word list in a more general sense. It doesn't mean that you need the list from the STL. There are many kinds of containers and the suitability of each depends on what you plan on doing with the data once it is read from the file. http://cplusplus.com/reference/stl/