Skip to content

Instantly share code, notes, and snippets.

Created August 12, 2013 14:53
Show Gist options
  • Save anonymous/6211515 to your computer and use it in GitHub Desktop.
Save anonymous/6211515 to your computer and use it in GitHub Desktop.
#include <string>
#include <fstream>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
vector<string> text_file;
ifstream ifs( "file1.txt" );
string temp;
//Henter en linje, legger den inn i vektoren.
while( getline( ifs, temp ) )
text_file.push_back( temp );
//Sorterer vektoren
sort(text_file.begin(), text_file.end());
//Skriver ut vektoren.
for (int i=0; i < text_file.size(); i++){
cout << text_file[i] << endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment