1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
#include <iostream> #include <fstream> using namespace std; int dump(ifstream *, bool dump = false); int main(int ac, char** av) { string filename = "activeuser.bin"; time_t t = time(NULL); if (ac > 1) { filename = string(av[1]); } ifstream in("n.txt"); if (!in) { cout << "open file fail" <<endl; } cout << "count:" << dump(&in, false) <<endl; cout << "use time:" << time(NULL) - t << endl; in.close(); return 0; } int dump(ifstream *in, bool dump) { unsigned char* ch = new unsigned char[8]; int i = 0, j = 0, pos = 0, cnt = 0; char c; while (i < 8) { *(ch+i) = ('\x01' << (7 - i)); //cout << *(ch + i) << endl; //printf("%d\n", *(ch+i)); i++; } while(!in->eof()) { *in >> c; j = 0; while (j < 8) { if ((ch[j] & c) == ch[j]) { cnt++; if (dump) { cout << pos * 8 + j << endl; } } j++; } pos++; } return cnt; } |