Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have the following c++ code and I am getting some errors when running it. void

ID: 3869993 • Letter: I

Question

I have the following c++ code and I am getting some errors when running it.

void ParseIntoXML::ParseTheFile(Scanner& in_scanner) {
#ifdef EBUG
Utils::log_stream << "enter ParseTheFile ";
#endif
vector <string> input_strings;
string input_value="";//reading from a vector
while (in_scanner.HasNext()){
   input_value = in_scanner.Next();
input_strings.push_back(input_value);}
//pushing out to the log file
for (auto iter = input_strings.begin; iter !=input_strings.end();++iter){
   utils::log_stream<<(*iter)<<end1;}
#ifdef EBUG
Utils::log_stream << "leave ParseTheFile ";
#endif
}

The errors when I run the program is the following:

parseintoxml.cc: In member function ‘void ParseIntoXML::ParseTheFile(Scanner&)’:
parseintoxml.cc:61:32: error: unable to deduce ‘auto’ from ‘input_strings.std::vector<std::__cxx11::basic_string<char> >::begin’
for (auto iter = input_strings.begin; iter !=input_strings.end();++iter){
                                ^
parseintoxml.cc:62:2: error: ‘utils’ has not been declared
utils::log_stream<<(*iter)<<end1;}
^
parseintoxml.cc:62:30: error: ‘end1’ was not declared in this scope
utils::log_stream<<(*iter)<<end1;}

How do I fix these erros?

Explanation / Answer

Errors Explained:

1.C++ is unable to deduce the type of iter so that should be explicitly defined. decltype(input_strings) can be used or best way is to define a iterator std::vector<string>::iterator iter.

2. 'u' in utils Should be Uppercase.

3.It is endl and not end1.

As the whole code is not provided I can't ensure it doesn't have any error.