Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualSerapth

Posted 19 August 2012 - 10:04 AM

Too slow, I was about to propose:

#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <algorithm>
using namespace std;
int main(int argc, char** argv)
{
ifstream stream;
stream.open("level.txt");
int numFiles;
stream >> numFiles;
cout << numFiles;
vector<string> results;
while(stream)
{
  string str;
  getline(stream,str);
  if(str != "") // Handle empty newlines
   results.push_back(str);
}
std::for_each(results.begin(),results.end(), [](string value) { cout << value << endl; });
return 0;
}


Wow, the C++ formatter is seriously broken...

#2Serapth

Posted 19 August 2012 - 10:04 AM

Too slow, I was about to propose:

[source lang="cpp"]#include <iostream>#include <string>#include <vector>#include <fstream>#include <algorithm>using namespace std;int main(int argc, char** argv){ifstream stream;stream.open("level.txt");int numFiles;stream >> numFiles;cout << numFiles;vector<string> results;while(stream){ string str; getline(stream,str); if(str != "") // Handle empty newlines results.push_back(str);}std::for_each(results.begin(),results.end(), [](string value) { cout << value << endl; });return 0;}[/source]

#1Serapth

Posted 19 August 2012 - 10:03 AM

Too slow, I was about to propose:

[source lang="cpp"]#include <iostream>#include <string>#include <vector>#include <fstream>#include <algorithm>using namespace std;int main(int argc, char** argv){ ifstream stream; stream.open("level.txt"); int numFiles; stream >> numFiles; cout << numFiles; vector<string> results; while(stream) { string str; getline(stream,str); if(str != "") // Handle empty newlines results.push_back(str); } std::for_each(results.begin(),results.end(), [](string value) { cout << value << endl; }); return 0;}[/source]

PARTNERS