Skip to content

Instantly share code, notes, and snippets.

@xslendix
Last active June 1, 2019 18:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xslendix/da4d424e7f529b2ef800b6abbfeb9da0 to your computer and use it in GitHub Desktop.
Save xslendix/da4d424e7f529b2ef800b6abbfeb9da0 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <fstream>
#include <string.h>
#include <termios.h>
#include <unistd.h>
#include <fcntl.h>
using namespace std;
int main() {
struct termios oldt, newt;
char ch, command[20];
int oldf;
tcgetattr(STDIN_FILENO, &oldt);
newt=oldt;
newt.c_lflag &= ~(ICANON | ECHO);
tcsetattr(STDIN_FILENO, TCSANOW, &newt);
oldf = fcntl(STDIN_FILENO, F_GETFL, 0);
fcntl(STDIN_FILENO, F_SETFL, oldf | O_NONBLOCK);
cout << "The precess can takes hours to even days to complete. To proceed, press ENTER else press CTRL+C to exit.\n";
char cha = 0x0;
while (cha != 0x0A) {
cha = getchar();
}
cout << "\nOpening file oh.txt for writing\n";
ofstream myfile;
myfile.open("oh.txt");
cout << "Writing to file\n";
myfile << 'o';
// string c = "4294967295"; // 32-bit
string c = "18446744073709551615"; // 64-bit
for (uint64_t b = 0; 2^64-1; b++) {
myfile << 'h';
printf("\r");
cout << b << "/" << c << " bytes written";
if (getchar() == 'q') break;
}
cout << "\nDone! Closing stream\n";
myfile.close();
tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
fcntl(STDIN_FILENO, F_SETFL, &oldt);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment