Skip to content

Instantly share code, notes, and snippets.

@residentkrm
Created September 10, 2015 21:05
Show Gist options
  • Save residentkrm/0ce252179f61fe81a376 to your computer and use it in GitHub Desktop.
Save residentkrm/0ce252179f61fe81a376 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <string>
#include <conio.h>
using namespace std;
int main(int argc, char *argv[]) {
string x = "This is C++.";
ofstream of("d:/tester.txt");
of << x << endl;
of << x << "2";
of.close();
vector<string> list;
ifstream in_stream;
string line;
in_stream.open("d:/tester.txt");
int count = 0;
while (!in_stream.eof())
{
++count;
std::getline(in_stream, line);
list.push_back(line);
cout << count << " " << line << endl;
}
in_stream.close();
sort(list.begin(), list.end());
_getch();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment