1234567891011121314151617181920212223242526272829303132333435363738394041
#include <fstream> #include <iostream> #include <algorithm> using namespace std; int main() { char buffer[100]; fstream myfile; // read text as binary data myfile.open("textfile.txt", ios_base::binary |ios_base::in); if (myfile) { // opening was success if (myfile.read(buffer, 100)) { // reading was success myfile.close(); cout << "unsorted numbers: "; for( int i = 0; i < 100; i++)cout << buffer[i] << " "; cout << endl; // sort number sort(buffer, buffer + 100); cout << "sorted numbers: "; for( int i = 0; i < 100; i++)cout << buffer[i] << " "; } else { cout << "It was error under reading!"; } } return 0; }