/* p3a processes a logfile (passed as string parameter logFilename)
* and generates a std::vector of std::string where each element is a non-empty
* line from the logfile
* The logfile may contain a number of empty lines in any position
*
* The order of the vector elements must be the same as that of the file
*/
std::vector<std::string> p3a(const std::string & logFilename);
std::vector<std::string> p3a(const std::string & logFilename) {
std::vector<std::string> result;
//open file
file = open(logFileName);
//read each line
line = getline(file);
while (has more lines from file) {
//add only if line is not empty
if (length of line not zero) {
result.push_back(line);
}
//read next line
line = getline(file);
}
//close file
close(file);
//return vector
return result;
}
Note: This is just a pseudo-code and not an actual one. Just get the idea and generate actual codes for that.