Posts

Showing posts from November, 2022

How to scramble the lines of a txt file

Image
ExSan++       1  ///---------Today's ExSan Code----------------------       2  // How to scramble the lines of a txt  file       3  const string dbFile = " ... stocki.txt";   // source       4  string dbScrambledFile = " ... stockScrambled.txt";   // destination       5        6  fstream ffrom, fto;       7  vector  fileLine;       8  string line;       9  unsigned short lineCounter(0);      10  ffrom.open(dbFile, ios::in);      11  if (!ffrom) {// source      12     printf("Error! cant find this file");         13     return;      14     exit(1);      15  }      16  do {      17     getline(ffrom, line);         18     fileLine.push_back(line);      19     ++lineCounter;      20  } while (!ffrom.eof());      21  ffrom.close();      22       23  boost::random::uniform_int_distribution<> uniformRndInt{ 0, lineCounter - 1 }; //#include <      24       25  fto.open(dbScrambledFile, ios::