for( const auto &i : lines )
out << i << std::endl;
this code is not working on VS10. how can i change it with iterators ?
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#define find_str( a, b ) std::find( a.begin(), a.end(), b ) == a.end()
int main( int argc, const char* argv[] )
{
std::ifstream in( "input.txt" );
std::ofstream out( "output.txt" );
std::vector<std::string> lines, sorted_lines;
if( !in )
{
std::cerr << "Error: Couldn't open file input.txt";
return -1;
}
std::string str, sorted_str;
while( in )
{
std::getline( in, str );
sorted_str = str;
std::sort( sorted_str.begin(), sorted_str.end() );
if( find_str( sorted_lines, sorted_str ) )
{
lines.push_back( str );
sorted_lines.push_back( sorted_str );
}
}
const auto i;
for( const auto &i : lines )
out << i << std::endl;
in.close();
out.close();
return 0;
}